Home All Groups Group Topic Archive Search About

Wrong Margins - How To ?

Author
22 Nov 2006 2:38 PM
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

Author
22 Nov 2006 4:03 PM
lord.zoltar
Antonio Paglia wrote:
Show quoteHide quote
> 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?