Hello,

I have problem the margin settings is not working. When I print it ignores the margin settings. Can some one tell me what I’m doing wrong.

Code:
Private PrintPageSettings As New PageSettings

    Private Sub PrintDocument1_PrintPage(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
        Dim rectDraw As New RectangleF(e.MarginBounds.Left, e.MarginBounds.Top, e.MarginBounds.Width, e.MarginBounds.Height)

        e.Graphics.DrawString(RichTextBox1.Text, RichTextBox1.Font, Brushes.Black, e.MarginBounds.Left, e.MarginBounds.Top)
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        PrintDialog1.Document = PrintDocument1
        Dim result As DialogResult = PrintDialog1.ShowDialog()
        If result = DialogResult.OK Then

            PageSetupDialog1.PageSettings = PrintPageSettings

            PageSetupDialog1.PageSettings.Margins.Top *= 0.5
            PageSetupDialog1.PageSettings.Margins.Bottom *= 0.5
            PageSetupDialog1.PageSettings.Margins.Left *= 0.5
            PageSetupDialog1.PageSettings.Margins.Right *= 0.5

            PrintDocument1.Print()
        End If
    End Sub

Thank you.