i am developing a school management software in which i have given a small handy functionality of a mini notepad so that it can make notice or doc within the software. I have taken a RichTextBox for this, Now my problem is that when i enter text in richtextbox without giving space in between ( eg. aaaaaaaa..........) continous for 2 lines and when i click on PrintPreview, it leave some space from it start displaying on left but the text leaves the page from right side. What i want is that i should a margin on both the side i.e. left & right side.
Below is my code on Print Document Click
Private Sub PrintDocument1_PrintPage_1(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
Dim font1 As New Font("Arial", 12, FontStyle.Regular)
'Dim formatF As StringFormat = StringFormat.GenericDefault
'formatF.Alignment = StringAlignment.Center
'formatF.LineAlignment = StringAlignment.Center
e.Graphics.DrawString(RichTextBox1.Text, font:=font1, brush:=Brushes.Black, x:=10, y:=50)
End Sub
So it basically do is represented in below images. Please have a look.
To print a string within a certain area of the page, specify a
Rectangle
which should contain the string.