|
I can get Font.size and printFont.GetHeight(PrintPageEventArgs.Graphics), number of characters in string to print. With the PrintDocument pd=new PrintDocument and printFont=new Font("Arial",10) I think it is possible to determine the length in inches on the printed sheet. I need this to make sure the string is within a area of the printedsheet, that is in fact I am printing labels on aA4sheet of paper. What information do I need and how to calculate the printed length of a string? | | new2ceecee Wednesday, October 07, 2009 4:53 PM | Inside of your graphics object, there's a method available to you:
"System.Drawing.Graphics.MeasureString(string, System.Drawing.Font)"
Other overloads exist for this functionality. - Marked As Answer byAland LiMSFT, Moderator3 hours 3 minutes ago
-
| | syntaxeater Wednesday, October 07, 2009 5:20 PM | Divide the height by pd.DefaultPageSettings.PrinterResolution.Y, which should get you the height in inches. Coding Light - Illuminated Ideas and Algorithms in SoftwareCoding Light Wiki � LinkedIn � ForumsBrowser- Marked As Answer byAland LiMSFT, Moderator3 hours 3 minutes ago
-
| | David M Morton Wednesday, October 07, 2009 5:20 PM | Yes, Graphics.MeasureString() will tell you how big the printed string will be. However, for labels you are usually more interested in getting the string in the right place. For that, use the Graphics.DrawString(string, Font, Brush, RectangleF, StringFormat) overload. The StringFormat argument determines how the string is fitted inside the rectangle.
Hans Passant.- Marked As Answer byAland LiMSFT, Moderator3 hours 3 minutes ago
-
| | nobugz Wednesday, October 07, 2009 6:10 PM | Inside of your graphics object, there's a method available to you:
"System.Drawing.Graphics.MeasureString(string, System.Drawing.Font)"
Other overloads exist for this functionality. - Marked As Answer byAland LiMSFT, Moderator3 hours 3 minutes ago
-
| | syntaxeater Wednesday, October 07, 2009 5:20 PM | Divide the height by pd.DefaultPageSettings.PrinterResolution.Y, which should get you the height in inches. Coding Light - Illuminated Ideas and Algorithms in SoftwareCoding Light Wiki � LinkedIn � ForumsBrowser- Marked As Answer byAland LiMSFT, Moderator3 hours 3 minutes ago
-
| | David M Morton Wednesday, October 07, 2009 5:20 PM | Yes, Graphics.MeasureString() will tell you how big the printed string will be. However, for labels you are usually more interested in getting the string in the right place. For that, use the Graphics.DrawString(string, Font, Brush, RectangleF, StringFormat) overload. The StringFormat argument determines how the string is fitted inside the rectangle.
Hans Passant.- Marked As Answer byAland LiMSFT, Moderator3 hours 3 minutes ago
-
| | nobugz Wednesday, October 07, 2009 6:10 PM |
|