0

我正在尝试使用 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>

打印输出看起来像这样 每页一行

4

1 回答 1

0

该问题通过向 TitledWindow 对象(PrintDataGrid 的包装器)添加“高度”参数来解决。当高度设置为 800 时,内容会打印到整页上,并且不显示滚动条。

<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" title="Open Time" height="800">
<mx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        import mx.core.*;

        [Bindable]
        private var openSequences:ArrayCollection;

        public function initPrintDataGrid(sequences:ArrayCollection):void {
            openSequences = sequences;
        }
    ]]>
</mx:Script>

<!-- 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>
于 2012-05-16T20:24:48.690 回答