ActionScript 2.0 Language Reference |
|
|
|
| ActionScript classes > PrintJob > start (PrintJob.start method) | |||
public start() : Boolean
Displays the operating system's print dialog boxes and starts spooling. The print dialog boxes let the user change print settings. When the PrintJob.start() method returns successfully, the following read-only properties are populated, representing the user's print settings:
|
Property |
Type |
Units |
Notes |
|---|---|---|---|
|
PrintJob.paperHeight |
Number |
Points |
Overall paper height. |
|
PrintJob.paperWidth |
Number |
Points |
Overall paper width. |
|
PrintJob.pageHeight |
Number |
Points |
Height of actual printable area on the page; any user-set margins are ignored. |
|
PrintJob.pageWidth |
Number |
Points |
Width of actual printable area on the page; any user-set margins are ignored. |
|
PrintJob.orientation |
String |
"portrait" or "landscape". |
After the user clicks OK in the Print dialog box, the player begins spooling a print job to the operating system. You should issue any ActionScript commands that affect the printout, and you can use PrintJob.addPage() commands to send pages to the spooler. You can use the read-only height, width, and orientation properties this method populates to format the printout.
Because the user sees information such as "Printing page 1" immediately after clicking OK, you should call the PrintJob.addPage() and PrintJob.send() commands as soon as possible.
If this method returns false (for example, if the user clicks Cancel instead of OK in the operating system's Print dialog box), any subsequent calls to PrintJob.addPage() and PrintJob.send() will fail. However, if you test for this return value and don't send PrintJob.addPage() commands as a result, you should still delete the PrintJob object to make sure the print spooler is cleared, as shown in the following example:
var my_pj:PrintJob = new PrintJob();
var myResult:Boolean = my_pj.start();
if(myResult) {
// addPage() and send() statements here
}
delete my_pj;
Availability: ActionScript 1.0; Flash Player 7
Boolean - A Boolean value: true if the user clicks OK when the print dialog boxes appear; false if the user clicks Cancel or if an error occurs.
The following example shows how you might use the value of the orientation property to adjust the printout:
// create PrintJob object
var my_pj:PrintJob = new PrintJob();
// display print dialog box
if (my_pj.start()) {
// boolean to track whether addPage succeeded, change this to a counter
// if more than one call to addPage is possible
var pageAdded:Boolean = false;
// check the user's printer orientation setting
// and add appropriate print area to print job
if (my_pj.orientation == "portrait") {
// Here, the printArea measurements are appropriate for an 8.5" x 11"
// portrait page.
pageAdded = my_pj.addPage(this,{xMin:0,xMax:600,yMin:0,yMax:800});
}
else {
// my_pj.orientation is "landscape".
// Now, the printArea measurements are appropriate for an 11" x 8.5"
// landscape page.
pageAdded = my_pj.addPage(this,{xMin:0,xMax:750,yMin:0,yMax:600});
}
// send pages from the spooler to the printer
if (pageAdded) {
my_pj.send();
}
}
// clean up
delete my_pj;
addPage (PrintJob.addPage method), send (PrintJob.send method)
|
|
|
|