Get maximum resolution of printer

I am battling Windows to get the resolution of the printer.

On Mac, after PrinterSetupDialog, if I set MaxHorizontalResolution = -1 and the same for maxVerticalResolution, then HorizontalResolution and VerticalResolution reflect the maximum resolution of the printer.

On Windows, HorizontalResolution and VerticalResolution desperately stay at 72 dpi.

I thought about getting g.width and g.Height at the time of printing, but what I get is 600 dpi for a printer that is reporting 300 on Mac.

If I set MaxHorizontalResolution and maxVerticalResolution at 300, no error but still, HorizontalResolution and VerticalResolution desperately stay at 72 dpi.

Is there any way to get the actual resolution of the printer under Windows ?

Well, do you know. I drew bars every 300 dpi. They are spaced half an inch apart. So using g.Width works, and my printer is indeed 600 dpi, not 300 as Mac reports :slight_smile:

Michel, have you tried to set the resolutions to a super high value

MaxHorizontalResolution = 9999999

I found that it “usually” moves it DOWN to the closest resollution actually supported…

couldn’t hurt to see if that still works

No joy. Still 72.

But as long as I can infer maximum resolution from the printer graphics object, I guess I will be alright.

Thanks anyway :slight_smile:

There seem to be some calls:

https://msdn.microsoft.com/en-us/library/windows/desktop/dd183552(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/office/ff197339.aspx

^ Sample call

The Horizontal/Vertical resolution values are set after you open the printer. At least on Windows, Mac may act differently. I’ve never seen the values be wrong (after opening the printer).

Thank you Peter.

I have found two VB declare
https://gathering.tweakers.net/forum/list_messages/816769
https://support.microsoft.com/en-us/kb/194789

Great. Thanks.

Are you printing from your own developed application ?

As in some circumstances the application your are printing from could also change the printer settings.

It is my own app.

In Xojo 2016 R3, you could use and get the resolution with:

Dim g As graphics
Dim ps As PrinterSetup

ps = New printerSetup
ps.MaxHorizontalResolution = -1 '-1 to use max resolution
ps.MaxVerticalResolution = -1

If ps.pageSetupDialog Then
  g = OpenPrinterDialog(ps)
  If g <> Nil Then
    'Get Printer resolution with g.Width, g.Height
  End If
End If

2016 r4 broke printing and 2017 now allways will return 96.

Well, back to VB code from 15 years ago.