if I draw in the normal 72 DPI mode on the graphics object of the printer, I can also draw objects at point 0, 0 (x, y) without any problems. If I now set the maximum print resolution to -1 using MaxHorizontalResolution and MaxVerticalResolution and draw to 0, 0 I always have an offset of the coordinates. This looks like the minimum print margins to me. Can someone please give me an example of how I can still draw with the maximum resolution at point 0, 0?
Thank you very much.
Thats the current code snippet:
[code]Dim p As PrinterSetup = New PrinterSetup
If p.PageSetupDialog Then
’ Get best print resolution.
p.MaxHorizontalResolution = -1
p.MaxVerticalResolution = -1
Dim g As Graphics = OpenPrinterDialog§
If g <> Nil Then
Dim xScaleFactor, yScaleFactor As Double
// Set scaling factors based on PrinterSetup resolutions
xScaleFactor = p.HorizontalResolution / 72.0
yScaleFactor = p.VerticalResolution / 72.0
g.FillRect(0, 0, 36, 36) // you'll see there's an offset at the page
EDIT: OK, to clarify my question, since I see that the offset is also available in 72 DPI mode. Now I’m interested in whether the given x-position is calculated from the print margins, or from the zero point of the page?
The point (0,0) takes into account the print margins. If the print margins change, (0,0) will be at a different place on the physical paper. Ie., (0,0) is the top/left of the logical print area.
OK, what does this mean if I want to write an app in which the user can enter print margins himself using a form? If we take 1 inch, then the printer calculates the distance from the minimum print margins plus 1 inch? That would be fatal! Did I misunderstand something?
If you want precise positioning on the page, adjust all your X/Y coordinates by PrinterSetup.PageLeft and PrinterSetup.PageTop.
Perfect @Tim Hare . That’s what I missed. Thanks a lot.
Be careful, if you’re on Windows and you show the PageSetupDialog and the user leaves the default 1" margins intact, your 0-0 point will be inset by the default margin. If the user sets the margins to zero, then the page size it returns is correct and you can print in any valid location on the page. To avoid this, I don’t ever show the PageSetupDialog. This is a long-standing problem, nothing new. Apps running on MacOS don’t have this problem, only Windows.
You can print to negative coordinates. I usually obey the user’s margin settings, but occasionally, like when filling out a pre-printed form, I simply adjust by the margins to get precise positioning.