AS3 using PrintJob to print a MovieClip
Posted
by Chris Waugh
on Stack Overflow
See other posts from Stack Overflow
or by Chris Waugh
Published on 2009-09-14T15:26:01Z
Indexed on
2010/05/25
16:01 UTC
Read the original article
Hit count: 330
Hello,
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:
function printMovieClip(clip:MovieClip) {
var printJob:PrintJob = new PrintJob();
var numPages:int = 0;
var printY:int = 0;
var printHeight:Number;
if ( printJob.start() ) {
/* Resize movie clip to fit within page width */
if (clip.width > printJob.pageWidth) {
clip.width = printJob.pageWidth;
clip.scaleY = clip.scaleX;
}
numPages = Math.ceil(clip.height / printJob.pageHeight);
/* Add pages to print job */
for (var i:int = 0; i < numPages; i++) {
printJob.addPage(clip, new Rectangle(0, printY, printJob.pageWidth, printJob.pageHeight));
printY += printJob.pageHeight;
}
/* Send print job to printer */
printJob.send();
/* Delete job from memory */
printJob = null;
}
}
printMovieClip( testMC );
Unfortunately this is not working as expected i.e. printing the full width of the Movieclip and doing page breaks on the length.
Any help with this would be greatly appreciated.
Many thanks,
Chris
© Stack Overflow or respective owner