flex列印操作(FlexPrintJob)還有分頁列印操作具體實現

來源:互聯網
上載者:User

首先要匯入 import mx.printing.FlexPrintJob;
import mx.printing.PrintAdvancedDataGrid;
1.使用FlexPrintJob進行列印操作
1.如果沒有分頁和下拉框的時候 複製代碼 代碼如下:public function doPrint():void{
var printer:FlexPrintJob = new FlexPrintJob();
if(printer.start()){
printer.addObject(body);
printer.send();
}
}

這個方法即可 下面的可以使用,由於我使用的是Flex3,Flex3裡面沒有標籤“PrintDataGrid”,只有“PrintAdvancedDataGrid”。所以下面就使用(“PrintAdvancedDataGrid”,“AdvancedDataGrid ”,“DataGrid ”)這三種方式,切記上面的方式只適合於單個頁面(資料較少)且沒有下拉框 複製代碼 代碼如下:<mx:PrintAdvancedDataGrid id="body" x="188" y="232">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="username"/>
<mx:AdvancedDataGridColumn dataField="password"/>
</mx:columns>
</mx:PrintAdvancedDataGrid>

--------------------------------------------------------------------------------------
[/code]
<mx:AdvancedDataGrid id="body" x="188" y="232">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="username"/>
<mx:AdvancedDataGridColumn dataField="password"/>
</mx:columns>
</mx:AdvancedDataGrid>
[/code]
----------------------------------------------------------------------------------------- 複製代碼 代碼如下:<mx:DataGrid id="body" x="188" y="232">
<mx:columns>
<mx:DataGridColumn dataField="username"/>
<mx:DataGridColumn dataField="password"/>
</mx:columns>
</mx:DataGrid>

----------------------------------------------------------------------------------------------------------------------------------------------------------
如果要使用分頁效果,則必須使用標籤"PrintAdvancedDataGrid"(Flex3中的標籤)才能夠實現分頁效果 複製代碼 代碼如下:private function doPrint():void{
var PrintJob:FlexPrintJob = new FlexPrintJob();
if(PrintJob.start()){
addChild(body);
//設定的列印視圖屬性
while(true){
PrintJob.addObject(body);
if(body.validNextPage){
body.nextPage();
}else{
break;
}
}
}
PrintJob.send();
}

這個方法,所對應的標籤是: 複製代碼 代碼如下:<mx:PrintAdvancedDataGrid id="body" x="188" y="232">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="username"/>
<mx:AdvancedDataGridColumn dataField="password"/>
</mx:columns>
</mx:PrintAdvancedDataGrid>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.