Package | flash.printing |
Class | public class PrintJobOptions |
Inheritance | PrintJobOptions Object |
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9 |
options
parameter of the PrintJob.addPage()
method.
For more information about addPage()
, see the PrintJob class.
More examples
Related API Elements
Property | Defined By | ||
---|---|---|---|
constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | ||
pixelsPerInch : Number = NaN
Specifies the resolution to use for bitmaps, in pixels per inch. | PrintJobOptions | ||
printAsBitmap : Boolean = false
Specifies whether the content in the print job is printed as a bitmap or as a vector. | PrintJobOptions | ||
printMethod : String
Specifies that the Flash runtime chooses the most appropriate
printing method, or that the author wishes to explicitly select
vector or bitmap printing. | PrintJobOptions | ||
prototype : Object [static]
A reference to the prototype object of a class or function object. | Object |
Method | Defined By | ||
---|---|---|---|
PrintJobOptions(printAsBitmap:Boolean = false)
Creates a new PrintJobOptions object. | PrintJobOptions | ||
Indicates whether an object has a specified property defined. | Object | ||
Indicates whether an instance of the Object class is in the prototype chain of the object specified
as the parameter. | Object | ||
Indicates whether the specified property exists and is enumerable. | Object | ||
Sets the availability of a dynamic property for loop operations. | Object | ||
Returns the string representation of this object, formatted according to locale-specific conventions. | Object | ||
Returns the string representation of the specified object. | Object | ||
Returns the primitive value of the specified object. | Object |
pixelsPerInch | property |
public var pixelsPerInch:Number = NaN
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 2 |
Specifies the resolution to use for bitmaps, in pixels per inch.
The default value is Number.NaN
, indicating that the native
printer resolution is used.
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.
printAsBitmap | property |
public var printAsBitmap:Boolean = false
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9 |
Specifies whether the content in the print job is printed as a bitmap or as a vector.
The default value is false
, for vector printing.
If the content that you're printing includes a bitmap image,
set printAsBitmap
to true
to include any
alpha transparency and color effects.
If the content does not include bitmap images, print
the content in higher quality vector format (the default option).
For example, to print your content as a bitmap, use the following syntax:
var options:PrintJobOptions = new PrintJobOptions(); options.printAsBitmap = true; myPrintJob.addPage(mySprite, null, options);
Note:Adobe AIR does not support vector printing on Mac OS.
Related API Elements
Example ( How to use this example )
- The constructor loads the picture (
image.jpg
) using theLoader
andURLRequest
objects. It also checks if an error occurred during loading. Here the file is assumed to be in the same directory as the SWF file. The SWF file needs to be compiled with Local Playback Secuirty set to Access Local Files Only. - When the picture is loaded (the event is complete), the
completeHandler()
method is called. - The
completeHandler()
method, creates aBitmapData
object, and loads the picture (bitmap) in it. A rectangle is drawn in theSprite
object (frame
) and thebeginBitmapFill()
method is used to fill the rectangle with the picture (aBitmapData
object). AMatrix
object also is used to scale the image to fit the rectangle. (Note that this will distort the image. It is used in this example to make sure the image fits.) Once the image is filled, theprintPage()
method is called. - The
printPage()
method creates a new instance of the print job and starts the printing process, which invokes the print dialog box for the user, and populates the properties of the print job. TheaddPage()
method contains the details about the print job. Here, the frame with the picture (a Sprite object) is set to print as a bitmap and not as a vector.options
is an instance ofPrintJobOptions
class and its propertyprintAsBitmap
is set totrue
in order to print as a bitmap (default setting is false).
Note: There is very limited error handling defined for this example.
package { import flash.display.Sprite; import flash.display.Loader; import flash.display.Bitmap; import flash.display.BitmapData; import flash.printing.PrintJob; import flash.printing.PrintJobOptions; import flash.events.Event; import flash.events.IOErrorEvent; import flash.net.URLRequest; import flash.geom.Matrix; public class printAsBitmapExample extends Sprite { private var frame:Sprite = new Sprite(); private var url:String = "image.jpg"; private var loader:Loader = new Loader(); public function printAsBitmapExample() { var request:URLRequest = new URLRequest(url); loader.load(request); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, completeHandler); loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler); } private function completeHandler(event:Event):void { var picture:Bitmap = Bitmap(loader.content); var bitmap:BitmapData = picture.bitmapData; var matrix:Matrix = new Matrix(); matrix.scale((200 / bitmap.width), (200 / bitmap.height)); frame.graphics.lineStyle(10); frame.graphics.beginBitmapFill(bitmap, matrix, true); frame.graphics.drawRect(0, 0, 200, 200); frame.graphics.endFill(); addChild(frame); printPage(); } private function ioErrorHandler(event:IOErrorEvent):void { trace("Unable to load the image: " + url); } private function printPage ():void { var myPrintJob:PrintJob = new PrintJob(); var options:PrintJobOptions = new PrintJobOptions(); options.printAsBitmap = true; myPrintJob.start(); try { myPrintJob.addPage(frame, null, options); } catch(e:Error) { trace ("Had problem adding the page to print job: " + e); } try { myPrintJob.send(); } catch (e:Error) { trace ("Had problem printing: " + e); } } } }
printMethod | property |
printMethod:String
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 2 |
Specifies that the Flash runtime chooses the most appropriate printing method, or that the author wishes to explicitly select vector or bitmap printing.
Set the property to one of the following values defined in the
PrintMethod
class:
PrintMethod.AUTO
: Specifies that vector or bitmap printing is chosen automatically, based on the content to be printed. Vector printing will be used whenever the content can be faithfully reproduced by that method. If transparency or certain other effects are present, bitmap printing will be used instead.PrintMethod.VECTOR
: Speifies vector printing. This setting is the same as settingprintAsBitmap
tofalse
.PrintMethod.BITMAP
: Specifies bitmap printing. Same as settingprintAsBitmap
totrue
.
If printMethod is set to one of these supported values, then printAsBitmap is ignored.
The default value is null
; the printAsBitmap property is
used.
Implementation
public function get printMethod():String
public function set printMethod(value:String):void
Throws
ArgumentError — The printMethod specified is not one of the
values defined in the PrintMethod class.
|
Related API Elements
PrintJobOptions | () | Constructor |
public function PrintJobOptions(printAsBitmap:Boolean = false)
Language Version: | ActionScript 3.0 |
Runtime Versions: | AIR 1.0, Flash Player 9 |
Creates a new PrintJobOptions object. Pass this object
to the options
parameter of the PrintJob.addPage()
method.
printAsBitmap:Boolean (default = false ) — If true , this object is printed as a bitmap.
If false , this object is printed as a vector.
If the content that you're printing includes a bitmap image,
set the Note:Adobe AIR does not support vector printing on Mac OS. |
Related API Elements
Mon Nov 28 2011, 06:48 AM -08:00