Results 1 to 2 of 2

Thread: Printing page issue with RichText

  1. #1

    Thread Starter
    Addicted Member tgf-47's Avatar
    Join Date
    Feb 2010
    Location
    CapeTown, South Africa -34.01244,18.337415
    Posts
    209

    Unhappy 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:
    1. Sub PrintPreview()
    2.         Dim Print_Preview As New PrintPreviewDialog
    3.         Print_Preview.Document = PreparePrintDocument()
    4.         Print_Preview.WindowState = FormWindowState.Maximized
    5.         Print_Preview.ShowDialog()
    6.     End Sub
    7.  
    8.     Private Function PreparePrintDocument() As PrintDocument
    9.         Dim Print_Document As New PrintDocument
    10.         AddHandler Print_Document.PrintPage, AddressOf Print_PrintPage
    11.         Return Print_Document
    12.     End Function
    13.  
    14.     Private Sub Print_PrintPage(ByVal sender As Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs)
    15.         Dim Page As String
    16.         Page = Me.rt.Text
    17.         e.Graphics.DrawString(Page, rt.Font, Brushes.Black, 50, 50)
    18.         e.HasMorePages = False
    19.     End Sub

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width