The settings for a PrintJob instance can be changed at
any time after it is constructed. This includes changing settings
between
addPage()
calls and after a print job has
been sent or terminated. Some settings, such as the
printer
property,
apply to the entire print job, not individual pages. Those settings
must be set before a call to
start()
or
start2()
.
The
selectPaperSize()
method can be called to
set the default paper size in the Page Setup and Print dialogs.
It can also be called during a print job to set the paper size for
a range of pages. It is called using constants defined in the
PaperSize
class,
as in this example, which selects a number 10 envelope size:
import flash.printing.PrintJob;
import flash.printing.PaperSize;
var myPrintJob:PrintJob = new PrintJob();
myPrintJob.selectPaperSize(PaperSize.ENV_10);
Use the
printer
property to get or set the name
of the printer for the current print job. By default it is set to
the name of the default printer. The
printer
property
is
null
if no printers are available or the system
does not support printing. To change the printer, first get the
list of available printers using the
printers
property.
That property is a Vector whose String elements are available printer
names. Set the
printer
property to one of those
String values to make that printer the active one. The
printer
property
of an active print job cannot be changed. Attempts to change it
after a successful call to
start()
or
start2()
and
before the job is sent or terminated fail. Here is an example of setting
this property:
import flash.printing.PrintJob;
var myPrintJob:PrintJob = new PrintJob();
myPrintJob.printer = "HP_LaserJet_1";
myPrintJob.start();
The
copies
property gets the value for the number
of copies set in the operating system’s Print dialog. The
firstPage
and
lastPage
properties
get the page range. The
orientation
property gets
the paper orientation setting. These properties can be set to override
the values from the Print dialog. The following example sets these
properties:
import flash.printing.PrintJob;
import flash.printing.PrintJobOrientation;
var myPrintJob:PrintJob = new PrintJob();
myPrintJob.copies = 3;
myPrintJob.firstPage = 1;
myPrintJob.lastPage = 3;
myPrintJob.orientation = PrintJobOrientation.LANDSCAPE;
The following read-only settings associated with
PrintJob
provide
helpful information on the current printer setup:
-
paperArea
: The rectangular bounds of
the printer medium, in points.
-
printableArea
: The rectangular bounds of
the printable area, in points.
-
maxPixelsPerInch
: The physical resolution
of the current printer, in pixels per inch.
-
isColor
: The ability of the current printer
to print color (returns
true
if the current printer
can print color).
See
Printing example: Page setup and print options
.