sheet.graphics.lineStyle(1,0x000000);
sheet.graphics.drawRect(0,0,100,200);
sheet.graphics.endFill();
var txt:TextField = new TextField();
txt.height = 200;
txt.width = 100;
txt.wordWrap = true;
txt.text = str;
if(imgValue != null){
var img:Sprite = new Sprite();
img.graphics.beginFill(0x0066cc);
img.graphics.drawRect(imgValue.x, imgValue.y, imgValue.width, imgValue.height);
img.graphics.endFill();
sheet.addChild(img);
}
sheet.addChild(txt);
}
private function printPages():void{
var pj:PrintJob = new PrintJob();
var pagesToPrint:uint = 0;
if(pj.start()){
if(pj.orientation == PrintJobOrientation.LANDSCAPE){
throw new Error("Page is not set to an orientation of portrait.");
}
sheet1.height = pj.pageHeight;
sheet1.width = pj.pageWidth;
sheet2.height = pj.pageHeight;
sheet2.width = pj.pageWidth;
sheet3.height = pj.pageHeight;
sheet3.width = pj.pageWidth;
try{
pj.addPage(sheet1);
pagesToPrint++;
}catch(e:Error){
//响应错误
}
try{
pj.addPage(sheet2);
pagesToPrint++;
}catch(e:Error){
//响应错误
}
try{
pj.addPage(sheet3);
pagesToPrint++;
}catch(e:Error){
//响应错误
}
if(pagesToPrint>0){
pj.send();
}
}
}
}
}
多页打印效果图:
