Printing page issue with RichText
The printing works fine, except for the fact that it cuts off my text that did not fit into the page. eg.
TEXT:
abababababababbabababa
PAGE:
-----------------|
PAGE |
|
All that will be printed is this:
abababababababb
How do I set it to automatically "wordwrap" or something to the size of the page that will be printed?
I'm using this code to print my text:
.net Code:
Sub PrintPreview()
Dim Print_Preview As New PrintPreviewDialog
Print_Preview.Document = PreparePrintDocument()
Print_Preview.WindowState = FormWindowState.Maximized
Print_Preview.ShowDialog()
End Sub
Private Function PreparePrintDocument() As PrintDocument
Dim Print_Document As New PrintDocument
AddHandler Print_Document.PrintPage, AddressOf Print_PrintPage
Return Print_Document
End Function
Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
Dim Page As String
Page = Me.rt.Text
e.Graphics.DrawString(Page, rt.Font, Brushes.Black, 50, 50)
e.HasMorePages = False
End Sub
Re: Printing page issue with RichText
Have a look at they documentation for DrawString. It has numerous overloads, allowing you to do various things. Also, unless you know for a fact that there won't be enough text to fill the page, you're going to have test the size of the text you're printing to determine how much can fit on the page and only draw that much, saving the rest for the next page.