Re: Word Wrap while Printing
From: Ron Allen (rallen_at__nospam_src-us.com)
Date: 02/17/05
- Next message: Ben: "Re: Hyperlink in DataGrid"
- Previous message: Ben: "Re: Multicast question."
- In reply to: Jeff B.: "Re: Word Wrap while Printing"
- Next in thread: Jeff Louie: "Re: Word Wrap while Printing"
- Messages sorted by: [ date ] [ thread ]
Date: Thu, 17 Feb 2005 09:26:22 -0500
Jeff,
To get the # of lines used for the wrapped printing you can use the
MeasureString method that takes a SizeF argument (#7 of 7 in my Intellisense
list). The SizeF should be the width and height of the rectangle you are
printing in and, of course, use the same StringFormat as the DrawString
call. This overload has two out parameters nline, and nchars that return
the # of lines and characters that fit. If nchars is less than the length
of the string the string would be truncated on output. You can use this to
see if remaining text fits on the rest of the page and then advance the
baseline by the # of lines returned after you draw the string.
Ron Allen
"Jeff B." <jsb@community.nospam> wrote in message
news:eEksTeJFFHA.2540@TK2MSFTNGP09.phx.gbl...
> Thanks Kevin and Picho for the info. You both understood exactly what I
> was after and the "rectangle" method you mention almost does exactly what
> I need. The only part I'm missing is being able to increment the line
> count by how many lines the text was wrapped so the subsequent lines
> display correctly and the pages break correctly.
>
> I think I'm going to take a slightly different approach and break the
> lines out programmatically as I print them. I'll post back any
> successes - or failures :-)
>
> --- Jeff
>
> --
>
> Jeff Bramwell
> Digerati Technologies, LLC
> www.digeratitech.com
>
> Manage Multiple Network Configurations with Select-a-Net
> www.select-a-net.com
>
> "Jeff B." <jsb@community.nospam> wrote in message
> news:OWA0Te9EFHA.560@TK2MSFTNGP15.phx.gbl...
>> Has anyone come across a decent algorithm for implementing word wrap
>> features in .net printing? I have a small component that uses basic
>> printing techniques (i.e. e.Graphics.DrawString in a PrintPage event of a
>> PrintDocument object) to send some formatted text to the printer.
>> However, if the lines are too long they run off the page rather than
>> wrapping around. I'm sure I can spend the time and come up with a word
>> wrapping algorithm but figured why go through the trouble if someone
>> already knows of one :-)
>>
>> --- Thanks, Jeff
>>
>> --
>>
>> Jeff Bramwell
>> Digerati Technologies, LLC
>> www.digeratitech.com
>>
>> Manage Multiple Network Configurations with Select-a-Net
>> www.select-a-net.com
>>
>>
>
>
- Next message: Ben: "Re: Hyperlink in DataGrid"
- Previous message: Ben: "Re: Multicast question."
- In reply to: Jeff B.: "Re: Word Wrap while Printing"
- Next in thread: Jeff Louie: "Re: Word Wrap while Printing"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|