我正在尝试使用 flex 打印作业从数据网格中打印数据。网格中有大约 40 行填充了数据。
但是,当我尝试打印时,应用程序崩溃了,但打印了一些页面。
这是我的代码:
protected function openPrintDialogMonth():void {
doPrintingMonth();
}
protected function doPrintingMonth():void {
var printjob2:FlexPrintJob;
var printTemplate:printTemplate = new printTemplate();
var printDataGrid:PrintDataGrid;
printjob2 = new FlexPrintJob();
if( printjob2.start() )
{
var currentYear:Date = new Date();
var dataArray:Array = new Array();
trace( "Width/Height:", printjob2.pageWidth, "/", printjob2.pageHeight );
printDataGrid = new PrintDataGrid();
printTemplate.width = 1368;
printTemplate.height = 800;
printTemplate.data = gridReport.dataProvider;
printTemplate.editData();
printTemplate.year = String(currentYear.getFullYear());
printTemplate.printDataGrid.columns = gridReport.columns;
printTemplate.printDataGrid.columnWidth = gridReport.columnWidth;
printTemplate.printDataGrid.visible = true;
printTemplate.printDataGrid.showHeaders = true;
printTemplate.printDataGrid.sizeToPage = true;
printTemplate.scaleX = 1.00;
printTemplate.validateNow();
this.addElement( printTemplate );
if( !printTemplate.printDataGrid.validNextPage )
{
printjob2.addObject( printTemplate,FlexPrintJobScaleType.MATCH_WIDTH);
this.removeElement( printTemplate );
}
else
{
printjob2.addObject( printTemplate,FlexPrintJobScaleType.MATCH_WIDTH);
this.removeElement( printTemplate );
while( true )
{
printTemplate.printDataGrid.nextPage();
printjob2.addObject( printTemplate,FlexPrintJobScaleType.MATCH_WIDTH);
if( !printTemplate.printDataGrid.validNextPage )
break;
}
}
printjob2.send();
}
}