Printjob 的 addPage 方法需要 Sprite 作为第一个参数。
你想通过传递 0 来实现什么?
如果您想要空白页,请尝试:
var myPrintJob:PrintJob = new PrintJob();
myPrintJob.start(); /*Initiates the printing process for the operating system, calling the print dialog box for the user, and populates the read-only properties of the print job.*/
myPrintJob.addPage( new Sprite() );
myPrintJob.send();
另一个带有红色方块的例子:
var s:Sprite = new Sprite();
s.graphics.beginFill(0xFF0000);
s.graphics.drawRect(0, 0, 80, 80);
s.graphics.endFill();
var myPrintJob:PrintJob = new PrintJob();
myPrintJob.start(); /*Initiates the printing process for the operating system, calling the print dialog box for the user, and populates the read-only properties of the print job.*/
myPrintJob.addPage( s );
myPrintJob.send();
更多信息在这里。
要打印舞台的一部分,您可以:
1) 将要打印的所有内容包装在一个 sprite 中,并将该 sprite 传递给 addPage()。
或者
2) 使用位图数据
var bd :BitmapData = new BitmapData(stage.width, stage.height, false);
bd.draw(stage);
var b:Bitmap = new Bitmap (bd);
var s:Sprite = new Sprite();
s.addChild(b);
var printArea = new Rectangle( 0, 0, 200, 200 ); // The area you want to crop
myPrintJob.addPage( s, printArea );