Q:
How can I set landscape mode printing from within my application?
A:
Apple has always cautioned applications against trying to force
landscape printing on the user; however, there are certain apps in the
marketplace that have good reason to do this. Therefore, even though
there is no API in "classic" printing to set landscape mode, here is an
overview of a method that you may want to consider implementing if you
need to force the orientation of your print job:
- Call
PrValidate on your print record to ensure that the contents of
your print record are compatible with the current active printer driver.
- Look at the values of the paper rectangle in the print record. If it
is wider than it is tall, your user has already selected landscape mode. If it
is taller than it is wide, then you need to put up an alert asking your user to
choose landscape printing, followed by a call to
PrStlDialog so they can
set the orientation.
- Call
PrValidate again to ensure that the user did change to
landscape mode. If the paper rectangle is still taller than wide, go
back to step 2 and ask the user to set the orientation again because they
did not follow or did not understand the instructions in step 2.
- Save the print record with the correct orientation in the resource
fork of the preferences file, and read it back in each time the user
needs to print. For information on how to save print records, refer to
the Premier Issue of develop 1990, page 58. By saving and
using the saved print record, the user is only bothered by the
PrStlDialog *once*. Thereafter, the print record is restored from
preferences when printing needs to occur.
- If the user changes printer drivers in the Chooser, the call to
PrValidate will fail, and PrDefault must be called.
This will make a new print record for the new printer driver, and it will default to portrait mode
(not landscape mode), so, go back to step 2.
Note:
Every printer driver implements its orientation settings
differently, so this method may not work across all printer drivers.
Also, if your customer frequently changes printers, this method may not
be an acceptable solution.
|
|