0

我正在尝试使用 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();
            }
        }
4

1 回答 1

0

今天在使用 Adob​​e Air 的 Flash 中遇到了同样的问题。在我的情况下,我必须在开始打印作业之前先将显示对象添加到舞台。将其添加到显示列表会强制重绘,这可能是打印作业所需要的。

于 2012-10-17T16:59:33.983 回答