My code for printing landscape works in five different applications I have
used it in.
The author of the PrintJob class made some poor choices when coding it and
you have to code around it. Here is my method explained with comments:
function printCertificate() {
// reference to the movieclip to be printed
var mc = MC_Certificate;
// gets the real width and height of the movieclip before rotation
// this is important because PrintJob uses the original dimensions
// of the clip prior to rotating when setting the min/max bounds
// but everything else it uses refers to the rotated clip props
var realW = mc._width;
var realH = mc._height;
// instantiate printjob
_pj = new PrintJob();
var pageCount = 0;
if (_pj.start()) {
var portrait, cXscale, cYscale;
var orient = _pj.orientation;
if (orient.toLowerCase() != "landscape") {
// if the user left it as portrait (the default)
// then rotate the clip 9 degrees for printing
portrait = true;
mc._rotation = 90;
// put the movieclip _x back to 0 after rotate
// if you don't do this, printjob will crop it
mc._x = mc._width;
// scales the clip up to fill the page
// if you don't want to do this, comment these lines
cXscale = (_pj.pageWidth / realH) * 100;
cYscale = (_pj.pageHeight / realW) * 100;
} else {
// scales the clip up to fill the page
// if you don't want to do this, comment these lines
cXscale = (_pj.pageWidth / realW) * 100;
cYscale = (_pj.pageHeight / realH) * 100;
}
// scales the clip up to fill the page
// if you don't want to do this, comment this line
mc._xscale = mc._yscale = Math.min(cXscale, cYscale);
// adds the page using the real width and height for bounds
if (_pj.addPage(mc, {xMin:0, xMax:realW, yMin:0,
yMax:realH})) {
pageCount++;
}
}
if (pageCount > 0) {
_pj.send();
}
// reset the movieclip back to its original state
// all of this happens without the user seeing it
mc._xscale = mc._yscale = 100;
if (portrait) {
mc._rotation = 0;
mc._x = 0;
mc._y = 0;
}
delete _pj;
}
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com