PrintJob class

Availability

Flash Player 7.

Description

The PrintJob class lets you create content and print it to one or more pages. This class, in addition to offering improvements to print functionality provided by the print() method, lets you render dynamic content offscreen, prompt users with a single print dialog box, and print an unscaled document with proportions that map to the proportions of the content. This capability is especially useful for rendering and printing external dynamic content, such as database content and dynamic text.

Additionally, with properties populated by PrintJob.start(), your document can access your user's printer settings, such as page height, width, and orientation, and you can configure your document to dynamically format Flash content that's appropriate for the printer settings.

Method summary for the PrintJob class

You must use the methods for PrintJob class in the order listed in the following table.

Method

Description

PrintJob.start()

Displays the operating system's print dialog boxes and starts spooling.

PrintJob.addPage()

Adds one page to the print spooler.

PrintJob.send()

Sends spooled pages to the printer.

Constructor for the PrintJob class

Availability

Flash Player 7.

Usage

my_pj = new PrintJob()

Parameters

None.

Returns

Nothing.

Description

Constructor; creates a PrintJob object that you can use to print one or more pages.

To implement a print job, use these methods in the sequence shown:

// create PrintJob object
my_pj = new PrintJob();                        // instantiate object

// display print dialog box
my_pj.start();                                 // initiate print job

// add specified area to print job
// repeat once for each page to be printed
my_pj.addPage([params]);                       // send page(s) to spooler
my_pj.addPage([params]); 
my_pj.addPage([params]); 
my_pj.addPage([params]); 

// send pages from the spooler to the printer
my_pj.send();                                   // print page(s)

// clean up
delete my_pj;                                    // delete object

In your own implementation of PrintJob objects, you should check for return values from PrintJob.start() and PrintJob.addPage() before continuing to print. See the examples for PrintJob.addPage().

You cannot create a PrintJob object until any PrintJob object that you already created is no longer active (that is, it either completed successfully or failed). If you try to create a second PrintJob object (by calling new PrintJob()) while the first PrintJob object is still active, the second PrintJob object will not be created.

Example

See PrintJob.addPage().

See also

PrintJob.addPage(), PrintJob.send(), PrintJob.start()