Does Graphics.PageUnit apply to margin values? RRS feed

  • Question

  • I want to set the printerDocument to use the DefaultPageSettings.Margins :

      mPd.OriginAtMargins = True

    Also I want to draw using Pixels:

    I set e.Graphics.PageUnit = GraphicsUnit.Pixel in PrintPage

    Best I can determine MSDN says the margins are (always?) specified in hundreds of an inch. I can't find anywhere it says that GraphicsUnt effects that. Can you?

    I ask because when I print it looks like my margins (set to 100) are very small but if I remove the e.Graphics.PageUnit = GraphicsUnit.Pixel line the margins become about an inch.

    Does Graphics.PageUnit apply to margin values?

    Thursday, December 7, 2017 4:22 PM

All replies

  • Margins are a pagesettings property. Not a graphics surface property. And it appears the margins are only supported in 1/100ths of inch in vb. I could be wrong.

    The margins have their own coordinate system not tied to the graphics surface.

    The printer graphics surface can be scaled with the usual graphics things.

    Since the printer and screen resolution pixels (dots) per inch is device specific, using inches sort of avoids the conversion problems (to the user). If the default units are hundredths of an inch that is device independent.

    Friday, December 8, 2017 2:22 AM
  • Hi Scholar,

    About e.Graphics.PageUnit = GraphicsUnit.Pixel , you can take a look this case, this has a more detailed introduction.

    Best Regards,


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact

    Friday, December 8, 2017 10:07 AM