Results 1 to 2 of 2

Thread: Why PrintDocument Margins different than Printed Paper Margins ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2018
    Posts
    77

    Why PrintDocument Margins different than Printed Paper Margins ?

    I try to Draw a Rectangle around a paper. I set Left, Top margins and Width and Height...

    when I print this page and when I measurement left and top margins are around 3mm difrent than seted margins.

    for example when I set left and top margins ZERO
    On PrintPreviewDialog. Margins are appear Left and Top Margins are ZERO

    But...
    After I printed page left margin is 3.2 mm and top margin is 3 mm around.


    When I use this code ;

    e.Graphics.PageUnit = GraphicsUnit.Millimeter
    e.Graphics.ResetTransform()
    e.Graphics.TranslateTransform((e.MarginBounds.X - e.PageSettings.HardMarginX) / 100.0F, (e.MarginBounds.X - e.PageSettings.HardMarginY) / 100.0F)
    PrintDocument1.OriginAtMargins = True

    this time left and top margins are 4 mm difrent than printed paper margins.

    This is what I try ..

    Code:
    Private Sub PrintDocument1_PrintPage_1(sender As Object, e As Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
            Dim grpX As Graphics = e.Graphics
            e.Graphics.PageUnit = GraphicsUnit.Millimeter
            e.Graphics.ResetTransform()
            e.Graphics.TranslateTransform((e.MarginBounds.X - e.PageSettings.HardMarginX) / 100.0F, (e.MarginBounds.X - e.PageSettings.HardMarginY) / 100.0F)
            PrintDocument1.OriginAtMargins = True
    
            Dim style As FontStyle = FontStyle.Regular
            Dim fonts As Font = New Font(New FontFamily("Monotype Corsiva"), 12, style)
            Dim pen As New System.Drawing.Pen(System.Drawing.Color.Black, 0.01F)
            pen.DashStyle = Drawing.Drawing2D.DashStyle.Solid
            Dim pen2 As New System.Drawing.Pen(System.Drawing.Color.Blue, 0.01F)
            Dim pen3 As New System.Drawing.Pen(System.Drawing.Color.Purple, 0.01F)
            e.Graphics.Clear(Color.White)
    
            Dim wdth As Decimal
            Dim hght As Decimal
            Dim topSide As Decimal
            Dim leftSide As Decimal
            Dim horzGap As Decimal
            Dim VertGap As Decimal
            Dim HorLabel As Decimal
            Dim VerLabel As Decimal
    
            topSide = 12.9
            hght = (33.9)
            VerLabel = 8
            VertGap = 0
    
            leftSide = 4.65
            wdth = (99.1)
            HorLabel = 2
            horzGap = (2.5)
    
            grpX.DrawRectangle(pen2, CDec(0.1), CDec(0.1), CDec(209.8), CDec(296.7))
            grpX.DrawRectangle(pen, CDec(leftSide), CDec(topSide), CDec(200.7), CDec(271.2))
             
        End Sub
    Is it possible to get same Margin result on the paper as set on PrintDocument ?

  2. #2
    PowerPoster Poppa Mintin's Avatar
    Join Date
    Mar 2009
    Location
    Bottesford, North Lincolnshire, England.
    Posts
    2,500

    Re: Why PrintDocument Margins different than Printed Paper Margins ?

    Hi Nicomendox,

    I would suggest that you check that your printer is set to 'No Margins'.
    Or 'Boarderless Printing'.

    Poppa
    Last edited by Poppa Mintin; Apr 23rd, 2020 at 12:04 PM.
    Along with the sunshine there has to be a little rain sometime.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width