Wrong Margins - How To ?

A

Antonio Paglia

On VS2005:

I define my own print document class like this

Class MyPrintDocument
Inherits PrintDocument

Private Sub PrintDocumentPrinter_PrintPage(ByVal sender As Object, ByVal
e As System.Drawing.Printing.PrintPageEventArgs) Handles Me.PrintPage
e.Graphics.DrawRectangle(Pens.Black,
Me.DefaultPageSettings.Margins.Left, Me.DefaultPageSettings.Margins.Top,
200, 200)
e.HasMorePages = False
End Sub

End Class

Then, I want to print at top/upper corner an square of 2x2 inchs. Margins
have been configured to 1 inch

Dim pd As New MyPrintDocument
pd.DefaultPageSettings.PaperSize = New PaperSize("CustomSize", 827,
1169)
pd.DefaultPageSettings.Margins = New Margins(100, 100, 100, 100)
pd.Print()


I have notice that the rectangle is not at 1 inch from the left and top
edge, but 1.1 inch to left and 1.2 inch at top margin. I can't print exactly
at 1 inch or any other margin. Is There a way to do this ??

Please, help me
TIA

Antonio
 
L

lord.zoltar

Antonio said:
On VS2005:

I define my own print document class like this

Class MyPrintDocument
Inherits PrintDocument

Private Sub PrintDocumentPrinter_PrintPage(ByVal sender As Object, ByVal
e As System.Drawing.Printing.PrintPageEventArgs) Handles Me.PrintPage
e.Graphics.DrawRectangle(Pens.Black,
Me.DefaultPageSettings.Margins.Left, Me.DefaultPageSettings.Margins.Top,
200, 200)
e.HasMorePages = False
End Sub

End Class

Then, I want to print at top/upper corner an square of 2x2 inchs. Margins
have been configured to 1 inch

Dim pd As New MyPrintDocument
pd.DefaultPageSettings.PaperSize = New PaperSize("CustomSize", 827,
1169)
pd.DefaultPageSettings.Margins = New Margins(100, 100, 100, 100)
pd.Print()


I have notice that the rectangle is not at 1 inch from the left and top
edge, but 1.1 inch to left and 1.2 inch at top margin. I can't print exactly
at 1 inch or any other margin. Is There a way to do this ??

Please, help me
TIA

Antonio

In my experience, it never prints EXACTLY the way it's told. I usually
find the printing is off by +/- 2 cm. Maybe it's the printer (I only
have 1 to experiment with). What happens when you print on a different
printer?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top