Set print document margins

09-25-2004, 02:26 AM
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

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

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.

M.Sadegh Samiei

09-25-2004, 10:40 AM
Look at the example I posted here:

This example is more complex than what you are doing, but pay attention to where I define margins and default spacing.

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum