C# print Vertical text

http://stackoverflow.com/questions/7655001/how-do-i-print-vertical-text-in-c-sharp-that-prints-up-stringformat-directionv
http://stackoverflow.com/questions/955362/rotate-text-for-printing
http://stackoverflow.com/questions/4460258/c-rotated-text-align
http://msdn.microsoft.com/en-us/library/aa287525(v=vs.71).aspx
http://msdn.microsoft.com/en-us/library/aa287530(v=vs.71).aspx
http://www.c-sharpcorner.com/blogs/580/how-to-rotating-text-90-degrees-in-gdi.aspx

复制代码
 1  int width = (int)(80 * 100 / 25.4 + 1);// (int)(190 * 100 / 25.4 + 1);  //216*97
 2             int height = (int)(226 * 100 / 25.4 + 1);
 3             // 橫向  false //縱向
 4             //this.printDocument1.DefaultPageSettings.PaperSize = new PaperSize("Custum", 500, 300);
 5             PaperSize pkCustomSize = new PaperSize("Custum", 320, (int)(226 * 100 / 25.4 + 1)); //六福的工資單規格(int)(101 * 100 / 25.4 + 1) 400小了,401大了(int)(80 * 100 / 25.4 + 1)
 6             this.printDocument1.DefaultPageSettings.PaperSize = pkCustomSize;
 7             printDocument1.DefaultPageSettings.Landscape = false; //true縱向   //false橫向
 8 
 9             StringFormat format = new StringFormat();
10             format.Alignment = StringAlignment.Center;
11 
12             SizeF txt = e.Graphics.MeasureString("中國工商銀行深圳市分行", this.Font);
13             SizeF sz = new SizeF(width, height); //e.Graphics.VisibleClipBounds.Size;
14 
15             //90 degrees
16             e.Graphics.TranslateTransform(sz.Width, 0);
17             e.Graphics.RotateTransform(90.0F);
18             e.Graphics.DrawString("中國建設銀行深圳市分行", this.Font, Brushes.Black, new RectangleF(30, 50, sz.Height, sz.Width), format);
19             e.Graphics.ResetTransform();
20 
21             //180 degrees
22             e.Graphics.TranslateTransform(sz.Width, sz.Height);
23             e.Graphics.RotateTransform(180.0F);
24             e.Graphics.DrawString("中國人民銀行深圳市分市", this.Font, Brushes.Black, new RectangleF(30, 50, sz.Width, sz.Height), format);
25             e.Graphics.ResetTransform();
26 
27             //270 degrees
28             e.Graphics.TranslateTransform(0, sz.Height);
29             e.Graphics.RotateTransform(270.0F);
30             e.Graphics.DrawString("中國工商銀行深圳市分行", this.Font, Brushes.Black, new RectangleF(30, 50, sz.Height, sz.Width), format);
31             e.Graphics.ResetTransform();
32 
33             //0 = 360 degrees
34             e.Graphics.TranslateTransform(0, 0);
35             e.Graphics.RotateTransform(0.0F);
36             e.Graphics.DrawString("深圳市農村商業銀行寶安支行", this.Font, Brushes.Black, new RectangleF(30, 50, sz.Width, sz.Height), format);
37             e.Graphics.ResetTransform();
38 
39 
40             //RectangleF tabbor = new RectangleF(0, 0, 44.35F, 150.0F);
41             //StringFormat sf = new StringFormat();
42             //sf.FormatFlags = StringFormatFlags.DirectionVertical;
43             //String drawString = "First Line Second Line";
44             //Font drawFont = new Font("Arial", 16);
45             //SolidBrush drawBrush = new SolidBrush(Color.Black);
46             //float x = 0F;
47             //float y = 0F;
48             //StringFormat drawFormat = new StringFormat();
49             //drawFormat.FormatFlags = StringFormatFlags.DirectionVertical;
50             ////Do 180 degree Rotatation Transformation
51             //e.Graphics.RotateTransform(180, MatrixOrder.Append);
52             //e.Graphics.TranslateTransform(50, 150, MatrixOrder.Append);
53             //e.Graphics.DrawString(drawString, drawFont, Brushes.Black, tabbor, sf);
54             //e.Graphics.DrawRectangle(Pens.Black, Rectangle.Round(tabbor)); 
复制代码

 

posted @   ®Geovin Du Dream Park™  阅读(753)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
阅读排行:
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
< 2013年4月 >
31 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 1 2 3 4
5 6 7 8 9 10 11
点击右上角即可分享
微信分享提示