flex打印操作(FlexPrintJob)還有分頁(yè)打印操作具體實(shí)現(xiàn)
更新時(shí)間:2013年04月28日 15:45:09 作者:
如果要使用分頁(yè)效果,則必須使用標(biāo)簽"PrintAdvancedDataGrid"(Flex3中的標(biāo)簽)才能夠?qū)崿F(xiàn)分頁(yè)效果,感興趣的朋友可以參考下
首先要導(dǎo)入 import mx.printing.FlexPrintJob;
import mx.printing.PrintAdvancedDataGrid;
1.使用FlexPrintJob進(jìn)行打印操作
1.如果沒(méi)有分頁(yè)和下拉框的時(shí)候
public function doPrint():void{
var printer:FlexPrintJob = new FlexPrintJob();
if(printer.start()){
printer.addObject(body);
printer.send();
}
}
這個(gè)方法即可 下面的可以使用,由于我使用的是Flex3,Flex3里面沒(méi)有標(biāo)簽“PrintDataGrid”,只有“PrintAdvancedDataGrid”。所以下面就使用(“PrintAdvancedDataGrid”,“AdvancedDataGrid ”,“DataGrid ”)這三種方式,切記上面的方式只適合于單個(gè)頁(yè)面(數(shù)據(jù)較少)且沒(méi)有下拉框
<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>
----------------------------------------------------------------------------------------------------------------------------------------------------------
如果要使用分頁(yè)效果,則必須使用標(biāo)簽"PrintAdvancedDataGrid"(Flex3中的標(biāo)簽)才能夠?qū)崿F(xiàn)分頁(yè)效果
private function doPrint():void{
var PrintJob:FlexPrintJob = new FlexPrintJob();
if(PrintJob.start()){
addChild(body);
//設(shè)置的打印視圖屬性
while(true){
PrintJob.addObject(body);
if(body.validNextPage){
body.nextPage();
}else{
break;
}
}
}
PrintJob.send();
}
這個(gè)方法,所對(duì)應(yīng)的標(biāo)簽是:
<mx:PrintAdvancedDataGrid id="body" x="188" y="232">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="username"/>
<mx:AdvancedDataGridColumn dataField="password"/>
</mx:columns>
</mx:PrintAdvancedDataGrid>
import mx.printing.PrintAdvancedDataGrid;
1.使用FlexPrintJob進(jìn)行打印操作
1.如果沒(méi)有分頁(yè)和下拉框的時(shí)候
復(fù)制代碼 代碼如下:
public function doPrint():void{
var printer:FlexPrintJob = new FlexPrintJob();
if(printer.start()){
printer.addObject(body);
printer.send();
}
}
這個(gè)方法即可 下面的可以使用,由于我使用的是Flex3,Flex3里面沒(méi)有標(biāo)簽“PrintDataGrid”,只有“PrintAdvancedDataGrid”。所以下面就使用(“PrintAdvancedDataGrid”,“AdvancedDataGrid ”,“DataGrid ”)這三種方式,切記上面的方式只適合于單個(gè)頁(yè)面(數(shù)據(jù)較少)且沒(méi)有下拉框
復(fù)制代碼 代碼如下:
<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]
-----------------------------------------------------------------------------------------
復(fù)制代碼 代碼如下:
<mx:DataGrid id="body" x="188" y="232">
<mx:columns>
<mx:DataGridColumn dataField="username"/>
<mx:DataGridColumn dataField="password"/>
</mx:columns>
</mx:DataGrid>
----------------------------------------------------------------------------------------------------------------------------------------------------------
如果要使用分頁(yè)效果,則必須使用標(biāo)簽"PrintAdvancedDataGrid"(Flex3中的標(biāo)簽)才能夠?qū)崿F(xiàn)分頁(yè)效果
復(fù)制代碼 代碼如下:
private function doPrint():void{
var PrintJob:FlexPrintJob = new FlexPrintJob();
if(PrintJob.start()){
addChild(body);
//設(shè)置的打印視圖屬性
while(true){
PrintJob.addObject(body);
if(body.validNextPage){
body.nextPage();
}else{
break;
}
}
}
PrintJob.send();
}
這個(gè)方法,所對(duì)應(yīng)的標(biāo)簽是:
復(fù)制代碼 代碼如下:
<mx:PrintAdvancedDataGrid id="body" x="188" y="232">
<mx:columns>
<mx:AdvancedDataGridColumn dataField="username"/>
<mx:AdvancedDataGridColumn dataField="password"/>
</mx:columns>
</mx:PrintAdvancedDataGrid>
相關(guān)文章
flex4.0 利用外部項(xiàng)呈示器顯示List信息并添加圖片示例
利用外部項(xiàng)呈示器顯示List信息并添加圖片,在本文有個(gè)不錯(cuò)的示例,喜歡的朋友可以參考下,希望對(duì)大家有所幫助2013-09-09
Flex中怎么給表格中的滾動(dòng)條定位避免刷新回到原處
如果表格中的字段過(guò)多,會(huì)出現(xiàn)滾動(dòng)條,在將滾動(dòng)條滾到一定的位置時(shí),重新刷新又回到原處,本文教大家如何給滾動(dòng)條定位2014-10-10
flex調(diào)用webservice中的自定義類的方法
flex如何調(diào)用webservice中的自定義類,下面有個(gè)不錯(cuò)的示例,不了解的朋友可以參考下2014-01-01
Flex 改變樹(shù)結(jié)點(diǎn)圖標(biāo)的2種方法介紹
本文為大家介紹兩種方法改變樹(shù)結(jié)點(diǎn)圖標(biāo):根據(jù)是否有子結(jié)點(diǎn)進(jìn)行改變、根據(jù)結(jié)點(diǎn)的屬性,靈活改變圖標(biāo),具體實(shí)現(xiàn)如下,感興趣的朋友可以參考下哈,希望對(duì)大家有所幫助2013-07-07
flex 遍歷Object對(duì)象內(nèi)容的實(shí)現(xiàn)代碼
這篇文章主要介紹了flex 遍歷Object對(duì)象內(nèi)容的實(shí)現(xiàn)代碼,需要的朋友可以參考下2014-07-07
Flex動(dòng)態(tài)生成可編輯的DataGrid具體實(shí)現(xiàn)代碼
DataGrid具有以下功能:表頭是動(dòng)態(tài)生成的、每行都是有序號(hào)的、每行都是可以編輯、插入、刪除、修改,接下來(lái)為大家分享下Flex如何動(dòng)態(tài)生成可編輯的DataGrid2013-04-04

