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.
See also
Property | Defined By | ||
---|---|---|---|
constructor : Object
A reference to the class object or constructor function for a given object instance. | Object | ||
printAsBitmap : Boolean = false
Specifies whether the content in the print job is printed as a bitmap or as a vector. | 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 |
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, you should 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.
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); } } } }
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. You 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. |
See also
Fri Mar 19 2010, 02:45 AM -07:00