Set print document margins

samiei
09-25-2004, 03: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

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

http://www.xtremevbtalk.com/showthread.php?t=174384

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