|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Calculating text width when printingAny bright ideas on how I can calculate how wide a piece of text will be
when printing. When writing text to the screen in graphics mode I put it in a invisible text box to get its height and width (as suggested on this group). But obviously I cannot do that with the printer. Thanks "Jack Russell" <ja***@norubbish.tpg.com.au> schrieb Call a graphics object's MeasureString method. In the> Any bright ideas on how I can calculate how wide a piece of text > will be when printing. > When writing text to the screen in graphics mode I put it in a > invisible text box to get its height and width (as suggested on this > group). But obviously I cannot do that with the printer. PrintDocument.PrintPage event, you get it in e.graphics. Before printing you get it from System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics. Armin Armin Zingler wrote:
Show quoteHide quote > "Jack Russell" <ja***@norubbish.tpg.com.au> schrieb But dont' you have to put the string somewhere to measure it. If I put > >> Any bright ideas on how I can calculate how wide a piece of text >> will be when printing. >> When writing text to the screen in graphics mode I put it in a >> invisible text box to get its height and width (as suggested on this >> group). But obviously I cannot do that with the printer. > > > Call a graphics object's MeasureString method. In the > PrintDocument.PrintPage event, you get it in e.graphics. > Before printing you get it from > System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics. > > Armin > it on the printer how do I get it off if it is too long (or am I missing something basic here?).
Show quote
Hide quote
"Jack Russell" <ja***@norubbish.tpg.com.au> schrieb You only have to put it in the call to the function. The function returns > Armin Zingler wrote: > > "Jack Russell" <ja***@norubbish.tpg.com.au> schrieb > > > > > Any bright ideas on how I can calculate how wide a piece of text > > > will be when printing. > > > When writing text to the screen in graphics mode I put it in a > > > invisible text box to get its height and width (as suggested on > > > this group). But obviously I cannot do that with the printer. > > > > > > Call a graphics object's MeasureString method. In the > > PrintDocument.PrintPage event, you get it in e.graphics. > > Before printing you get it from > > System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics. > > > > Armin > > > But dont' you have to put the string somewhere to measure it. If I > put it on the printer how do I get it off if it is too long (or am I > missing something basic here?). the size. Then you can check the size to see whether it's too long. Armin Armin Zingler wrote:
Show quoteHide quote > "Jack Russell" <ja***@norubbish.tpg.com.au> schrieb There is something about .net that makes me miss the obvious!> >> Armin Zingler wrote: >> > "Jack Russell" <ja***@norubbish.tpg.com.au> schrieb >> > >> > > Any bright ideas on how I can calculate how wide a piece of text >> > > will be when printing. >> > > When writing text to the screen in graphics mode I put it in a >> > > invisible text box to get its height and width (as suggested on >> > > this group). But obviously I cannot do that with the printer. >> > >> > >> > Call a graphics object's MeasureString method. In the >> > PrintDocument.PrintPage event, you get it in e.graphics. >> > Before printing you get it from >> > System.Drawing.Printing.PrinterSettings.CreateMeasurementGraphics. >> > >> > Armin >> > >> But dont' you have to put the string somewhere to measure it. If I >> put it on the printer how do I get it off if it is too long (or am I >> missing something basic here?). > > > You only have to put it in the call to the function. The function > returns the size. Then you can check the size to see whether it's too long. > > Armin > Thanks, Jack |
|||||||||||||||||||||||