PrintJob class

just some code for reflection upon printing from flash..

Method 1
————
// print a pdf
// open up pdf
formprint_mc.onRelease = function() {
//getURL(”media/form101.pdf”, “_blank”);
print(this, “bframe”);
};

Method 2
————-
// open up print dialog and ask if wrong orientation
//
old_print_btn.onRelease = function() {
//print(formprint_mc, “bframe”);
// create PrintJob object
var my_pj:PrintJob = new PrintJob();

// display print dialog box
if (my_pj.start()) {
// boolean to track whether addPage succeeded, change this to a counter
// if more than one call to addPage is possible
var pageAdded:Boolean = false;

// check the user’s printer orientation setting
// and add appropriate print area to print job
if (my_pj.orientation == “portrait”) {
// Here, the printArea measurements are appropriate for an 8.5″ x 11″
// portrait page.
pageAdded = my_pj.addPage(this,{xMin:0,xMax:600,yMin:0,yMax:800});
}
else {
// my_pj.orientation is “landscape”.
// Now, the printArea measurements are appropriate for an 11″ x 8.5″
// landscape page.
pageAdded = my_pj.addPage(this,{xMin:0,xMax:750,yMin:0,yMax:600});
}

// send pages from the spooler to the printer
if (pageAdded) {
my_pj.send();
}
}

// clean up
delete my_pj;

};

Method 3
————-
//
// print a movieclip called formprint_mc
//
print_btn.onRelease = function(){
// create an instance of the PrintJob Class
var printJob_pj = new PrintJob();

// if user presses ok at the system default print dialog
if (printJob_pj.start())
{
// add frame 1 of theMovieclip to the print queue
printJob_pj.addPage( “formprint_mc”, { xMin:0, yMin:0, xMax:800,
yMax:600 }, { printAsBitmap:true }, 1 );

// send spooled info to printer
printJob_pj.send();
}

// clean up
delete printJob_pj

}

Leave a Reply

You must be logged in to post a comment.