For example, the following code uses a PrintUIOptions instance to specify the min and max page numbers when the Page Setup dialog is displayed:
This constant is used with the
This constant is used with the
This constant is used with the
If the content that you're printing includes a bitmap image,
set the
Note:Adobe AIR does not support vector printing on Mac OS.
The resolution setting is for both bitmap and vector printing. For bitmap printing, resolution controls how the entire page is rasterized. For vector printing, resolution controls how specific content, such as bitmaps and gradients, is rasterized.
If the content that you're printing includes a bitmap image,
set
For example, to print your content as a bitmap, use the following syntax:
Note:Adobe AIR does not support vector printing on Mac OS.
Note: There is very limited error handling defined for this example.
Set the property to one of the following values defined in the
If printMethod is set to one of these supported values, then printAsBitmap is ignored.
The default value is
Mobile Browser Support: This class is not supported in mobile browsers.
AIR profile support: This feature is supported
on all desktop operating systems, but it is not supported on mobile devices or AIR for TV devices. You can test
for support at run time using the
Use the
Additionally, with the PrintJob class's properties, you can read your user's printer settings, such as page height, width, and image orientation, and you can configure your document to dynamically format Flash content that is appropriate for the printer settings.
Note: ActionScript 3.0 does not restrict a PrintJob object
to a single frame (as did previous versions of ActionScript). However, since
the operating system displays print status information to the user after the
user has clicked the OK button in the Print dialog box, you should call
Additionally, a 15 second script timeout limit applies to the following intervals:
If any of the above intervals span more than 15 seconds, the next call to
Note: the constructor is set up such that one of three printing methods (one sheet per
page, two sheets per page, or printing on the top half of the page) can be selected, based on preference.
This example will not work correctly unless exactly two of the print methods are disabled using code
comments. The example is set up such that
PrintJob.addPage()
.
For example, you can replace the
// create PrintJob object var myPrintJob:PrintJob = new PrintJob(); // display Print dialog box, but only initiate the print job // if start returns successfully. if (myPrintJob.start()) { // add specified page to print job // repeat once for each page to be printed try { myPrintJob.addPage([params]); } catch(e:Error) { // handle error } try { myPrintJob.addPage([params]); } catch(e:Error) { // handle error } // send pages from the spooler to the printer, but only if one or more // calls to addPage() was successful. You should always check for successful // calls to start() and addPage() before calling send(). myPrintJob.send(); }
In AIR 2 or later, you can create and use multiple PrintJob instances. Properties set on
the PrintJob instance are retained after printing completes. This allows you to re-use a PrintJob
instance and maintain a user's selected printing preferences, while offering different printing
preferences for other content in your application. For content in Flash Player and in AIR prior to version 2, you cannot create a
second PrintJob object while the first one is still active.
If you create a second PrintJob object (by calling
A rectangle's width and height are pixel values. A printer uses points as print units of measurement. Points are a fixed physical size (1/72 inch), but the size of a pixel, onscreen, depends on the resolution of the particular screen. So, the conversion rate between pixels and points depends on the printer settings and whether the sprite is scaled. An unscaled sprite that is 72 pixels wide prints out one inch wide, with one point equal to one pixel, independent of screen resolution.
You can use the following equivalencies to convert inches or centimeters to twips or points (a twip is 1/20 of a point):
If you omit the
If you don't want to specify a value for
If
If
If the print job takes more than 15 seconds to complete an
If you pass a value for the
If you want to scale a Sprite object before you print it, set scale
properties (see
The Flash Player printing feature supports PostScript and non-PostScript printers. Non-PostScript printers convert vectors to bitmaps.
You can call this method at any time. Call this method before starting a print job to set the default paper size in the Page Setup and Print dialogs. Call this method while a print job is in progress to set the paper size for a range of pages within the job.
This method does not succeed if the call to the
The
Even when
In the following example, the min and max page settings in the Print dialog are set before the dialog is displayed to the user:
Note: If the user cancels the Print dialog box, the properties are not populated.
After the user clicks OK in the Print dialog box, the player begins spooling a print job to the operating system.
Because the operating system then begins displaying information to the user about the printing progress,
you should call the
Test to see if this method returns
For the given print job instance, if any of the following intervals last more than
15 seconds the next call to
After calling this method, the PrintJob instance can be reused. Wherever possible, the job's print settings are retained for subsequent use.
If this property is
If a color-or-grayscale value can't be determined, the value is
If you have not called
For each print job you execute with a PrintJob instance, set this property before
calling the
If the resolution cannot be determined, the value is a standard default value. The default value is 600 ppi on Linux and 360 ppi on Mac OS. On Windows, the printer resolution is always available, so no default value is necessary.
Note: For AIR 2 or later, set this property before
starting a print job to set the default orientation in the Page Setup and Print dialogs.
Set the property while a print job is in progress (after calling
Note: For AIR 2 or later, this property is deprecated. Use
Note: For AIR 2 or later, this property is deprecated. Use
Note: For AIR 2 or later, this property is deprecated. Use
Note: For AIR 2 or later, this property is deprecated. Use
Setting the value of this property attempts to select the printer immediately. If the printer selection fails, this property's value resets to the previous value. You can determine if setting the printer value succeeds by reading the value after attempting to set it, and confirming that it matches the value that was set.
The
The following table shows the approximate size for each paper type. The size is approximate because there is some variation among printer drivers. For example, the width of A4 paper can be 595.0, 595.2, 595.22 or 595.28 points depending on the driver.