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));