flex打印

The build-in print function provided by Adobe Flex is actually pretty straightforward. For a single page print, it is good enough. Here is how it works:


Things You Need

mx.printing.FlexPrintJob
Steps You Do

1. Create a FlexPrintJob Instance
var flexPrintJob: FlexPrintJob = new FlexPrintJob();

2. Start FlexPrintJob
flexPrintJob.start();

3. Add Target Component to FlexPrintJob
printJob.addObject(targetComponent);

4. Print
printJob.send();Sample Code


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
initialize="init()">

<mx:Script>
<![CDATA[
import mx.printing.FlexPrintJob;
import mx.collections.ArrayCollection;

[Bindable]
public var dataSource:ArrayCollection = new ArrayCollection();

private var totalRecords:Number = 15;

private function init():void {
for (var i:int = 1; i<=totalRecords; i++) {
var dataObject:Object = new Object();
dataObject.Name = "Name #" + i;
dataObject.Phone = "Phone #" + i;
dataObject.Address = "Address #" + i;
dataSource.addItem(dataObject);
}
}

private function doPrint():void {
var printJob:FlexPrintJob = new FlexPrintJob();
printJob.printAsBitmap=false; //提高文字清晰度
if (printJob.start()) {
printJob.addObject(myData);
printJob.send();
}
}

]]>
</mx:Script>

<mx:Panel title="Flex Tutorial - Print"
width="500" height="500"
horizontalCenter="0" verticalCenter="0"
horizontalAlign="center" verticalAlign="middle">

<mx:DataGrid id="myData"
dataProvider="{dataSource}"
width="400" height="400" />

<mx:Button label="Print" click="doPrint()"/>

</mx:Panel>

</mx:Application>
Conclusion

Adobe Flex provides FlexPrintJob to handle the print request. It is very simple to use. However, the biggest challenge is printing multiple pages. In the above sample code, if you change the code,

From:

private var totalRecords:Number = 15;
To:

private var totalRecords:Number = 100;
It will generate 100 records in the DataGrid. Guess how many of them will be printed if you click the Print button? Depends on your page and printer setting, maybe just 17-20. You will even see a ugly vertical scoll bar. The problem here is, FlexPrintJob itself can not SCOLL those Scollable Components like DataGrid or TextArea.

To resolve this problem, Adobe provides a workaround in Flex framework. In the next tutorial, we will see Printing Multiple Pages Using PrintDataGrid.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断路器保护灵敏度校验整改及剩余电流监测试点应用站用交流系统断

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值