Getting Current Page Setup

Hey all,

Is there a way to get the current page setup that is selected for an app? Yes, I could open a printer setup dialog, but I just want to use whatever is the default for the user rather than prompting for the setup. I’m generating a PDF from an image on a canvas and need to appropriately size/scale the image based on the users page size. I find it kind of odd to open a printer dialog when saving a file. And I could save it in my default paper size of letter, but that’s somewhat obnoxious as I may have users that are using A4 or legal, etc.

So how can I just get the current value? I’ve not seen a way to do that yet.

Well, I figured this out. You create a new PrinterSetup object but don’t open a PageSetupDialog. The PrinterSetup object will give you the size of the current selected (i.e.: default) page.

Are you sure that this gets you a good accurate PrinterSetup object? I ask because some time back one of the Gurus of RB found out that to get a fully accurate PrinterSetup you needed to go through the “new PrinterSetup” three times to have all of the printersetup fields accurately set. With his test program, which I still have, it still seems to be the case. Here is the code used in that test program:

[code] thePS = new PrinterSetup
thePS.MaxHorizontalResolution = -1
thePS.MaxVerticalResolution = -1
DisplayPSValues thePS, “New default PS”

ps = new PrinterSetup
ps.MaxHorizontalResolution = -1
ps.MaxVerticalResolution = -1
ps.SetupString = thePS.SetupString
thePS = ps
DisplayPSValues thePS, "First restore"

ps = new PrinterSetup
ps.MaxHorizontalResolution = -1
ps.MaxVerticalResolution = -1
ps.SetupString = thePS.SetupString
thePS = ps
DisplayPSValues thePS, "New Improved PS"
[/code]

The calls to DisplayPSValues are simply inserting lines in a listbox showing how the printersetup values are increasing in accuracy. Here is a shot of the listbox after executing the above code.

I just wish that I could remember the original posters name so as to give him credit here. This little program was written as he was going through the process of trying to get an accurate PrinterSetup without going through the dialog.

Here is an update to the previous post of mine. The above is true if you are compiling for Carbon. If compiling for Cocoa the info returned from the PrinterSetup code is always that shown in the third line of the listbox in my previous posting. So, it appears that whatever that little glitch was in Carbon, it has been corrected in Cocoa. For some reason, after my previous post it dawned on me that I had never tried that program in Cocoa so I went back and gave it a try under Cocoa and made this discovery.