Flex 打印功能的相关资料
2014-09-29 17:33
357 查看
http://livedocs.adobe.com/flex/3_cn/flash/printing/PrintJob.html
http://hi.baidu.com/_678/blog/item/2b6fedc4d6104ba18226acb0.html/cmtid/ea780af32563c0c20b46e04e
Flex提供两种打印方法:FlexPrintJob和PrintJob。
一、由于flex是打印图像的缘故,打印出来的文字、表格会不清晰。解决方法如下:
1、将FlexPrintJob中printAsBitmap属性设置为true。
2、使用PrintJob
二、打印缩放的解决方法
1、FlexPrintJob.addObject()中 scaleType 可以使用 FlexPrintJobScaleType,FlexPrintJobScaleType中定义了缩放的几种常见方式。
<pre>
2、PrintJob默认为不缩放输出,如需要缩放可以使用 scale 属性
var pj:PrintJob = new PrintJob();
var xScale:Number;
var yScale:Number;
xScale = (pj.pageWidth / this.height);
yScale = (pj.pageHeight / this.width);
this.scaleX= Math.min(xScale, yScale);
this.scaleY = Math.min(xScale, yScale);
pj.addPage(this);
pj.send();
三、打印的横向和纵向的控制
1、判断打印方向
利用 PrintJob.orientation(图像打印方向) 判断,PrintJob.orientation == PrintJobOrientation.LANDSCAPE 或者 PrintJobOrientation.PORTRAIT(LANDSCAPE表示横向打印;PORTRAIT表示纵向打印)
2、如需改变方向
this.rotation = 90; 即表示旋转90度
3、转动后文字消失问题
绝大多数文字在转动后会出现消失问题,是由于字体的缘故。有两个解决方法:
(1)将字体加载到文件中,该方法缺点是对于中文而言消耗大,通常达到几M,英文常在几十K内。也可以用外嵌字体,将字体打包成另外一个swf文件,然后由主flash文件去外部调用
<pre>
@font-face
{
fontFamily: "simhei";
src: url("assets/simhei.ttf");
fontWeight: normal;
}
global
{
fontFamily: "simsun";
fontWeight: normal;
fontSize: 10;
color:#000000;
}
</pre>
<pre>
private function completeHandle(e:Event):void{
fontClass = Object(e.target.content).loaderInfo.applicationDomain.getDefinition("Font1") as Class
Font.registerFont(fontClass);
tt.styleName = "myPlainStyle"
tt.rotation = 30;
}
</pre>
(2)使用Bitmap和Bitmapdata类,将文字转化为图像后再转动。该方法消耗小,但是文字有可能失真,而且对每个文字组件都要进行转换。
var bmp:BitmapData = new BitmapData(aa.width,aa.height,true);
bmp.draw(aa);
var bt:Bitmap = new Bitmap(bmp);
var img:Image = new Image();
img.source = bt;
img.x = 200;
img.y = 200;
img.rotation = 120;
addChild(img);
转动后显示图像页会随之改变所以打印发送完毕后,要将显示的内容再旋转会去,参考http://jessewarden.com/2008/09/forcing-landscape-printing-in-flex-2-3.html
4、多页打印可使用PrintJob,请参见adobe使用示例
http://livedocs.adobe.com/flex/3_cn/flash/printing/PrintJob.html
http://hi.baidu.com/_678/blog/item/2b6fedc4d6104ba18226acb0.html/cmtid/ea780af32563c0c20b46e04e
Flex提供两种打印方法:FlexPrintJob和PrintJob。
一、由于flex是打印图像的缘故,打印出来的文字、表格会不清晰。解决方法如下:
1、将FlexPrintJob中printAsBitmap属性设置为true。
2、使用PrintJob
二、打印缩放的解决方法
1、FlexPrintJob.addObject()中 scaleType 可以使用 FlexPrintJobScaleType,FlexPrintJobScaleType中定义了缩放的几种常见方式。
<pre>
2、PrintJob默认为不缩放输出,如需要缩放可以使用 scale 属性
var pj:PrintJob = new PrintJob();
var xScale:Number;
var yScale:Number;
xScale = (pj.pageWidth / this.height);
yScale = (pj.pageHeight / this.width);
this.scaleX= Math.min(xScale, yScale);
this.scaleY = Math.min(xScale, yScale);
pj.addPage(this);
pj.send();
三、打印的横向和纵向的控制
1、判断打印方向
利用 PrintJob.orientation(图像打印方向) 判断,PrintJob.orientation == PrintJobOrientation.LANDSCAPE 或者 PrintJobOrientation.PORTRAIT(LANDSCAPE表示横向打印;PORTRAIT表示纵向打印)
2、如需改变方向
this.rotation = 90; 即表示旋转90度
3、转动后文字消失问题
绝大多数文字在转动后会出现消失问题,是由于字体的缘故。有两个解决方法:
(1)将字体加载到文件中,该方法缺点是对于中文而言消耗大,通常达到几M,英文常在几十K内。也可以用外嵌字体,将字体打包成另外一个swf文件,然后由主flash文件去外部调用
<pre>
@font-face
{
fontFamily: "simhei";
src: url("assets/simhei.ttf");
fontWeight: normal;
}
global
{
fontFamily: "simsun";
fontWeight: normal;
fontSize: 10;
color:#000000;
}
</pre>
<pre>
private function completeHandle(e:Event):void{
fontClass = Object(e.target.content).loaderInfo.applicationDomain.getDefinition("Font1") as Class
Font.registerFont(fontClass);
tt.styleName = "myPlainStyle"
tt.rotation = 30;
}
</pre>
(2)使用Bitmap和Bitmapdata类,将文字转化为图像后再转动。该方法消耗小,但是文字有可能失真,而且对每个文字组件都要进行转换。
var bmp:BitmapData = new BitmapData(aa.width,aa.height,true);
bmp.draw(aa);
var bt:Bitmap = new Bitmap(bmp);
var img:Image = new Image();
img.source = bt;
img.x = 200;
img.y = 200;
img.rotation = 120;
addChild(img);
转动后显示图像页会随之改变所以打印发送完毕后,要将显示的内容再旋转会去,参考http://jessewarden.com/2008/09/forcing-landscape-printing-in-flex-2-3.html
4、多页打印可使用PrintJob,请参见adobe使用示例
http://livedocs.adobe.com/flex/3_cn/flash/printing/PrintJob.html
相关文章推荐
- (转)Flex 打印功能的相关资料
- Flex中不使用FelxPrintJob通过ExternalInterface直接调用JavaScript利用浏览器本身的功能进行打印
- flex 带打印预览功能的PrintJob
- 朋友网的部分代码:研究QQ相关功能的绝佳资料
- VC++实现打印功能相关
- Flex打印功能FlexPrintJob调用
- 小纸条功能相关资料转贴
- P2P平台的"我要借款"功能,是否需要上传借款人的相关资料
- 打印标签机器驱动程序及相关资料网址
- VC++实现打印功能相关
- arcgis for flex api version3.7 教程:10.打印服务功能简介
- flex 带打印预览功能的PrintJob
- Silverlight 4对比Flex 4打印功能
- Silverlight 4对比Flex 4打印功能
- ASP.NET网页打印(只打印相关内容/自写功能)
- ActionScript、Flex、AIR等RIA技术相关资料下载汇总
- 一周学会flex及flex相关学习资料
- Silverlight 4对比Flex 4打印功能
- flex 带打印预览功能的PrintJob
- java flex blazeds 开发相关资料