【问题标题】:How do you create a top margin when printing a PrintAdvancedDataGrid打印 PrintAdvancedDataGrid 时如何创建上边距
【发布时间】:2013-10-02 04:26:05
【问题描述】:

我的数据网格从页面的最顶部开始打印。我不知道如何向下移动数据网格。我在 FlexPrintJob 或 PrintAdvancedDataGrid 中看不到任何可以执行此操作的内容。我是否必须创建一个空白对象才能添加到 FlexPrintJob 对象的顶部?

任何帮助或有帮助的链接。

谢谢,

约翰

【问题讨论】:

    标签: apache-flex printing datagrid


    【解决方案1】:

    在尝试了 adobe 和其他对我完全不起作用的示例之后,我发现我必须将数据网格放在一个 vBox 中,在那里我可以在数据网格上方放置一个空白标题。正如所有示例所示,最好使用 vBox 组件来完成。

    下面是我想出的一个工作示例,它与我找到的示例有点不同。在 vBox 组件中,您可以做很多事情来增强打印作业。就我而言,我添加了标题和日期。

    希望这对那里的人有所帮助,

    约翰


    我正在使用通用函数来打印我的应用程序中可能包含的任何 AdvancedDataGrid...

    public function printAdvancedDataGridContents(advDG:AdvancedDataGrid, xmlListCollection:XMLListCollection, headerText:String):void
        {
            const printJob:FlexPrintJob = new FlexPrintJob();               
            if ( printJob.start() ) {
                //create an instance of the FormPrintView_ADG component containing the datagrid
                var thePrintView:FormPrintView_ADG = new FormPrintView_ADG();
                //add the component to my application
                FlexGlobals.topLevelApplication.addChild(thePrintView);
                //load the datagrid
                thePrintView.printDataGrid.dataProvider = xmlListCollection.copy();
                //format the datagrid
                thePrintView.printDataGrid.width = printJob.pageWidth-45; //set a left margin for the dg in a right justiified vBox
                thePrintView.printDataGrid.height = printJob.pageHeight-73; //page adjusted for header title and date
                thePrintView.printDataGrid.setStyle("fontSize", 8);
                thePrintView.printDataGrid.columns = advDG.columns;
                thePrintView.printDataGrid.setStyle("fontFamily", 'Times');
                thePrintView.printDataGrid.setStyle("color", 000000);
                //set the header text
                thePrintView.headerText.height = 45;
                thePrintView.headerText.width = printJob.pageWidth-20;
                thePrintView.headerText.text = "\r"+headerText;
                //add the first page to the print job
                printJob.addObject(thePrintView, FlexPrintJobScaleType.NONE);
                while (thePrintView.printDataGrid.validNextPage) {
                    // Move the next page of data to the top of the PrintDataGrid and add it to the printjob
                    thePrintView.printDataGrid.nextPage();
                    printJob.addObject(thePrintView, FlexPrintJobScaleType.NONE);                       
                }
                //print it and remove the component from my application
                printJob.send();
                FlexGlobals.topLevelApplication.removeChild(thePrintView);                  
            }
        }
    

    这是我正在使用的 vBox 组件...

    <?xml version="1.0"?>
    <mx:VBox xmlns:mx="http://www.adobe.com/2006/mxml"
        horizontalAlign="right"
        creationComplete="init();">
    
        <mx:Script>
        <![CDATA[
            [Bindable] private var date:String;
    
            private function init():void{
                date = new Date().toString();
                date = df.format(date);
            }
        ]]>
        </mx:Script>
    
        <mx:DateFormatter id="df" formatString="EEEE, MMMM D, YYYY"/>
        <!-- this header can contain a title or be left blank to create a top margin -->
        <mx:TextArea id="headerText"  borderThickness="0" color="#000000" fontWeight="bold"
                    textAlign="center" textDecoration="none"/>
        <!-- date label. set visible to false in the calling function if not needed -->
        <mx:Label color="#000000" fontSize="8" fontStyle="normal" fontWeight="normal" text="{date}"/>
        <!-- the data grid -->
        <mx:PrintAdvancedDataGrid id="printDataGrid"/>  
    </mx:VBox>    
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-03-29
      • 1970-01-01
      • 1970-01-01
      • 2010-12-05
      • 2017-03-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多