Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Wrap With PrintDocument Class

Status
Not open for further replies.

MangroBongacello

Programmer
Mar 20, 2001
189
SI
Hello,

I'm writing a procedure to print a text using PrintDocument class. If a line exceeds paper width, I would like a text to continue in the next line, which doestn't happen by default. How can I achieve this?

Thank you
Mangro
 
Bound your string in a rectangle. If you run the following example, you will see that it wraps the single line of text onto three lines
Code:
    Private Sub PD1_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PD1.PrintPage
        Dim s As String = "one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen "
        s &= "eighteen nineteen twenty twenty-one twenty-two twenty-three twenty-four twenty-five"

        e.Graphics.DrawString(s, Me.Font, Brushes.Black, New RectangleF(10, 10, 400, 400))
    End Sub
 
Yes, I was trying that but it did not work. I was testing it on a POS printer with 80mm paper roll. I set the size of the rectangle to the paper size, but the text wasn't wrapped. But then, after I sent the post here, I checked the printer propertis and found, that the paper size was set to A4. After I set it to 80 mm receipt, wrapping worked ok.

Thank you anyway.

Mangro
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top