我正在尝试使用 FlexPrintJob 在 Flex 3.2 中打印表格。我需要正常的打印行为 - 如果所有行都适合单页,则需要一页,如果有足够的数据可以填充一页以上,则需要整页的行,然后是部分填充的页面。不知何故,我每行得到一个页面,其中每个页面都有一个表头,然后是一行数据,然后是空白空间。
包含 15 行的表格会生成 15 页的文档。我在 Firefox 和 IE8 中得到相同的行为。
什么可能导致这种行为?谢谢你的帮助!
这是代码:
// The function to print the output.
public function onPrint():void {
var printJob:FlexPrintJob = new FlexPrintJob();
printJob.start();
var thePrintView:FormPrintView = new FormPrintView();
addChild(thePrintView);
thePrintView.initPrintDataGrid(openSequences);
// thePrintView.printOpenTimeGrid.dataProvider = printOpenTime.dataProvider;
thePrintView.validateNow();
thePrintView.width=printJob.pageWidth;
thePrintView.height=printJob.pageHeight;
printJob.addObject(thePrintView, FlexPrintJobScaleType.MATCH_WIDTH);
while (thePrintView.printOpenTimeGrid.validNextPage) {
//Put the next page of data in the view.
thePrintView.printOpenTimeGrid.nextPage();
//Queue the additional page.
printJob.addObject(thePrintView, FlexPrintJobScaleType.MATCH_WIDTH);
}
printJob.send();
removeChild(thePrintView);
this.onClose();
}
PrintDataGrid 直接位于 TitleWindow 对象中:
<!-- The data grid. The sizeToPage property is true by default, so the last
page has only as many grid rows as are needed for the data. -->
<mx:PrintDataGrid id="printOpenTimeGrid" dataProvider="{openSequences}" sizeToPage="true" width="100%" height="100%">
<mx:columns>
<mx:DataGridColumn dataField="startDate" headerText="Seq Date" width="70">
<mx:itemRenderer>
<mx:Component>
<mx:VBox>
<mx:DateFormatter id="startDateFormatter" formatString="M/D/YYY"/>
<mx:Label fontWeight="bold" text="{startDateFormatter.format(data.startDate)}"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="equipCode" headerText="EQP" width="40" />
<mx:DataGridColumn dataField="base" headerText="BSE" width="40" />
<mx:DataGridColumn dataField="sequenceNumber" headerText="SEQNO" width="45" />
<mx:DataGridColumn dataField="seat" headerText="ST" width="40" />
<mx:DataGridColumn headerText="DPRT" width="40">
<mx:itemRenderer>
<mx:Component>
<mx:VBox>
<mx:DateFormatter id="departTimeFormatter" formatString="JJNN"/>
<mx:Label fontWeight="bold" text="{departTimeFormatter.format(data.startDate)}"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="terminationDate" headerText="ARVL/DT" width="60" >
<mx:itemRenderer>
<mx:Component>
<mx:VBox>
<mx:DateFormatter id="arvDateFormatter" formatString="JJNN/DD"/>
<mx:Label fontWeight="bold" text="{arvDateFormatter.format(data.startDate)}"/>
</mx:VBox>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn dataField="tripValue" headerText="TTL" width="50" />
<mx:DataGridColumn dataField="blockType" headerText="Block Type" width="170" />
</mx:columns>
</mx:PrintDataGrid>
打印输出看起来像这样