旋转打印文本 [英] Rotate Text for printing

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

问题描述

我使用的PrintDocument打印页面。有一次,我想旋转文本90度和垂直方向打印,即print文本。任何想法???

I am using a PrintDocument to print a page. At one point I want to rotate the text 90 degrees and print it ie print text vertically. Any ideas ???

g.RotateTransform(90);

g.RotateTransform(90);

不适合的OnPaint工作。

does not work for OnPaint.

推荐答案

当你调用RotateTransform你需要在这里的坐标系统最终要注意。如果您运行下面的代码中,倾斜的文本将出现在左边缘的左侧;所以它不是可见的:

When you call RotateTransform you will need to pay attention to where the coordinate system ends up. If you run the following code, the "Tilted text" will appear to the left of the left edge; so it's not visible:

e.Graphics.Clear(SystemColors.Control);
e.Graphics.DrawString("Normal text", this.Font, SystemBrushes.ControlText, 10, 10);
e.Graphics.RotateTransform(90);
e.Graphics.DrawString("Tilted text", this.Font, SystemBrushes.ControlText, 10, 10);



既然你已经倾斜于纸面90度(顺时针),y坐标现在会一起移动左/右轴(从你的角度),而不是向上/向下。数字越大进一步向左侧。所以移动倾斜文成表面的可见部分,则需要减少y坐标:

Since you have tilted the drawing surface 90 degrees (clock wise), the y coordinate will now move along the right/left axis (from your perspective) instead of up/down. Larger numbers are further to the left. So to move the tilted text into the visible part of the surface, you will need to decrease the y coordinate:

e.Graphics.Clear(SystemColors.Control);
e.Graphics.DrawString("Normal text", this.Font, SystemBrushes.ControlText, 10, 10);
e.Graphics.RotateTransform(90);
e.Graphics.DrawString("Tilted text", this.Font, SystemBrushes.ControlText, 10, -40);



默认情况下,坐标系统的在所述表面的左上角ORIGO,所以这是。轴围绕RotateTransform将旋转表面

By default the coordinate system has its origo in the top left corner of the surface, so that is the axis around which RotateTransform will rotate the surface.

下面是说明了这一点的图像;黑色是调用RotateTransform之前,红色是调用RotateTransform后(35):

Here is an image that illustrates this; black is before call to RotateTransform, red is after call to RotateTransform(35):

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

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