Comment #8 on issue 146483 by
lgu...@gmail.com: Blank paper when printing
This code produces a blank page in PepperFlash using print preview. System
dialog works fine, FF works fine, IE works fine.....
public function printScreen() : void
{
const debug:Boolean = true;
//var pj:FlexPrintJob = new FlexPrintJob();
var pj:PrintJob = new PrintJob();
//pj.printAsBitmap = false;
if( !pj.start() ) return;
//
// Once the print job is started,
// the page dimensions will be set.
//
if (debug) Alert.show("Printer Page dimensions " + pj.pageWidth
+ " x " + pj.pageHeight + " ");
// page dimensions are zero prior to start.
var c:DrawingCanvas;
c = this.canvas;
//var b:Rectangle = c.getBounds(c);
//var b:Rectangle = new Rectangle(-c.x, -c.y, stage.width,
stage.height);
var b:Rectangle = new Rectangle(-c.x, -c.y, this.width,
this.height);
if (debug) Alert.show("canvas Width x Height " + c.width + "
x " + c.height + " stage Width x Height " + stage.width + " x " +
stage.height);
if (debug) Alert.show("rect x, y, w, h " + b.x + ", " +
b.y+ ", " + b.width+ ", " + b.height);
var drawWidth:int = pj.pageWidth - 2*printMarginSize;
var drawHeight:int =pj.pageWidth - 2*printMarginSize;
var f:Number = 1.0;
if (b.width > pj.pageWidth || b.height > pj.pageHeight) {
var wFactor:Number = drawWidth / b.width;
var hFactor:Number = drawHeight / b.height;
if (wFactor < hFactor) f = wFactor;
else f = hFactor;
}
var m:Matrix = new Matrix();
if (debug) Tracer.trace2("scale " + f);
m.scale(f, f);
m.translate(-(b.x * f), -(b.y * f));
var bitmap:BitmapData = new BitmapData(b.width * f, b.height *
f);
bitmap.draw(c, m, null, null, new Rectangle(0,0, bitmap.width,
bitmap.height), true);
if (debug)
Alert.show(" bitmap w,h=" + bitmap.width+ "," +
bitmap.height + " pageWidth, pageHeight=" + pj.pageWidth +"," +
pj.pageHeight);
var sheet1:Sprite = new Sprite();
sheet1.graphics.beginBitmapFill(bitmap);
sheet1.graphics.drawRect(0, 0, bitmap.width, bitmap.height);
sheet1.graphics.endFill();
var marginWidth:Number = (pj.pageWidth-bitmap.width)/2;
var marginHeight:Number = (pj.pageHeight-bitmap.height)/2;
var rect:Rectangle = new Rectangle(-marginWidth, -marginHeight,
pj.pageWidth, pj.pageHeight);
pj.addPage(sheet1, rect);
pj.send();
}
--
You received this message because this project is configured to send all
issue notifications to this address.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings