Hi @50683435 ,
You can define the StringFormat to wrap automatically, and then make the text drawing area a rectangle.
Here is my result.
Here is my code which you can refer to.
Private Sub PrintDocument1_PrintPage(sender As Object, e As PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim text As String = RichTextBox1.Text
Dim fmt As New StringFormat
fmt.LineAlignment = StringAlignment.Near
fmt.FormatFlags = StringFormatFlags.LineLimit
Dim size As New Size(PrintDocument1.DefaultPageSettings.PaperSize.Width, PrintDocument1.DefaultPageSettings.PaperSize.Height)
Dim r As New Rectangle(New Point(10, 10), size)
Dim printFont As New Font("Arial", 10, FontStyle.Regular)
e.Graphics.DrawString(text, printFont, Brushes.Black, r, fmt)
End Sub
Hope the code above could be helpful.
Best Regards.
Jiachen Li
----------
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.