I am currently trying to create a function which will allow me to pass in a MovieClip
and print it.
Here is the simplified version of the function:
I added a small fix that resets the MovieClip's dimensions after the printjob is done. The problem was that when you print something that is larger then your page, the code would also scale the movieclip on stage. So i Fixed that... nothing special but might be useful for other people :)
this code also fixes the fact that your transparent PNG's will ALSO be transparent on your print
protected function printMovieClip(clip:MovieClip):void {
var printJob:PrintJob = new PrintJob();
var printJobOptions:PrintJobOptions = new PrintJobOptions();
var numPages:int = 0;
var printArea:Rectangle;
var printHeight:Number;
var printY:int = 0;
var originalWidth:Number;
var originalHeight:Number;
if ( printJob.start() ) {
originalWidth = clip.width;
originalHeight = clip.height;
if (clip.width > printJob.pageWidth) {
clip.width = printJob.pageWidth;
clip.scaleY = clip.scaleX;
}
printArea = new Rectangle(0, 0, printJob.pageWidth/clip.scaleX, printJob.pageHeight/clip.scaleY);
numPages = Math.ceil(clip.height / printJob.pageHeight);
for (var i:int = 0; i < numPages; i++)
{
printJobOptions.printAsBitmap = true;
printJob.addPage(clip, printArea, printJobOptions);
printArea.y += printArea.height;
}
/* Send print job to printer */
printJob.send();
/* Delete job from memory */
printJob = null;
/* reset the clips width and height on stage so it is back at its original size*/
clip.width = originalWidth;
clip.height = originalHeight;
}
}