samiei
09-25-2004, 02:26 AM
Hi!
I am going to print something on a specific format. I programmed as:
------------------------------
Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim pd As New PrintDocument
AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
pd.Print()
End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs)
'Drawing everything I desire such as a rectangle
ev.Graphics.Clear(Color.White)
Dim pen As New Pen(New SolidBrush(Color.Black))
Dim rec As New Rectangle(0, 0, 100, 100)
ev.Graphics.DrawRectangle(pen, rec)
End Sub
------------------------------
But I am not able to set the print margins! Such command do not work:
------------------------------
'Three inches from every edge
pd.DefaultPageSettings.Margins = New Margins(300, 300, 300, 300)
------------------------------
Notify that ordinary printers would print the contents with a short margin even while you set (0,0) point as the start position.
Much obliged to you for your attention.
Regards!
M.Sadegh Samiei
I am going to print something on a specific format. I programmed as:
------------------------------
Private Sub Form_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim pd As New PrintDocument
AddHandler pd.PrintPage, AddressOf Me.pd_PrintPage
pd.Print()
End Sub
Private Sub pd_PrintPage(ByVal sender As Object, ByVal ev As System.Drawing.Printing.PrintPageEventArgs)
'Drawing everything I desire such as a rectangle
ev.Graphics.Clear(Color.White)
Dim pen As New Pen(New SolidBrush(Color.Black))
Dim rec As New Rectangle(0, 0, 100, 100)
ev.Graphics.DrawRectangle(pen, rec)
End Sub
------------------------------
But I am not able to set the print margins! Such command do not work:
------------------------------
'Three inches from every edge
pd.DefaultPageSettings.Margins = New Margins(300, 300, 300, 300)
------------------------------
Notify that ordinary printers would print the contents with a short margin even while you set (0,0) point as the start position.
Much obliged to you for your attention.
Regards!
M.Sadegh Samiei