在vb.net中打印镜像文本 [英] Print mirror text in vb.net

查看:76
本文介绍了在vb.net中打印镜像文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在半页上打印普通文本,在A4大小的纸张上打印另一半页面上的文本。我用printdocument对象来打印。普通文本打印正常,但现在我要打印相同txt的镜像。

如何在vb.net中执行此操作?

如何打印在vb.net中使用printdocument对象的镜像文本?

解决方案

在位图上打印文本,它们会镜像这个位图。



要在位图上写入,您可以先创建一个 System.Drawing.Bitmap 的实例,其大小和像素格式

http://msdn.microsoft.com/en-us/ library / system.drawing.bitmap.aspx [ ^ ]。



要绘制它,您需要创建一个的实例System.Drawing .Graphics 来自您的位图实例,使用此静态工厂方法 http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx [ ^ ]。



现在,您可以使用 System.Drawing.Graphics.DrawString 方法之一在位图上绘制文本:

http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx [ ^ ]。



要制作镜像,您需要使用图像像素。为此,请使用 LockBits 方法之一:

http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx [ ^ ]。



最后,使用 PrintDocument 绘制转换后的位图。



-SA

I want to print normal text on half page and mirror text on the other half page on an A4 size paper. I have used printdocument object to print. Normal text is printing fine, but now i want to print mirror image of the same txt.
How can i do this in vb.net?
how can i print a mirror text using printdocument object in vb.net?

解决方案

Print your text on bitmap and them mirror this bitmap.

To write on bitmap, you can first create an instance of System.Drawing.Bitmap with required size and pixel format:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.aspx[^].

To draw on it, you will need to create an instance of System.Drawing.Graphics from your instance of bitmap using this static factory method: http://msdn.microsoft.com/en-us/library/system.drawing.graphics.fromimage.aspx[^].

Now you can draw your text on bitmap using one of System.Drawing.Graphics.DrawString methods:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[^].

To make a mirror image, you will need to work a bit with image pixels. To do that, use one of LockBits methods:
http://msdn.microsoft.com/en-us/library/system.drawing.bitmap.lockbits.aspx[^].

Finally, use PrintDocument to draw converted bitmap.

—SA


这篇关于在vb.net中打印镜像文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆