注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Flex 技术博客

醉里挑灯看剑,梦回吹角连营

 
 
 

日志

 
 

Get started with AlivePDF ( Demo & Document)  

2009-03-24 16:11:50|  分类: AlivePDF |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

AlivePDF is a client side AS3 PDF generation library for Adobe Flash, Flex and AIR.

I collect the major API usage of AlivdPDF to here. If you can want more details please visit the http://www.alivepdf.org
I also write new demo to show how to use below APIs and the real effect.

如果点击下面按钮没反应,请单独打开例子View Demo

 

  1. Print simple text to PDF

·    addText()
The addText() method will put out text at a given coordinate. No word wrapping is done.
Code sample:
var pdf:PDF = new PDF( Orientation.LANDSCAPE, Unit.MM, Size.A4 );
pdf.setDisplayMode( Display.FULL_PAGE, Layout.SINGLE_PAGE );
var newPage:Page = new Page ( Orientation.PORTRAIT, Unit.MM, Size.A4 );
pdf.addPage( newPage );
pdf.setFont(FontFamily.ARIAL , Style.NORMAL, 20);
pdf.addText(“This is test text to print”.text,5,15);
·    writeText()
The writeText method will output text at the current location. You can also specify a link that clicking on the text will take you to.
pdf.setXY( 20, 20);
pdf.writeText ( 32, "This is linked text","http://www.google.com");

2.    Print multiple line text to PDF
·    addMultiCell()
addMultiCell ( pWidth:Number, pHeight:Number, pText:String, pBorder:=0, pAlign:String='J', pFill:int=0)
The addMultiCell lets you constrain text to a "cell" with a certain width. The cell starts at the current position and is the given width. The height IS NOT the height of the cell, it's the height of each line of text.
pdf.setFont(FontFamily.COURIER , Style.BOLD, 14);
pdf.addMultiCell(pdf.getCurrentPage().w-20,10,"This is multiple line text. Auto wordwrap for text without border.  Copyright (c) 2007 State Street Bank and Trust Corp. 225 Franklin Street, Boston ");
3.    Print Image
·    addImageStream()
The addImageStream method takes an incoming image as a ByteArray. This method can be used to embed high-quality images (300 dpi) to the PDF.
[Embed( source="/images/ssLogo.jpg", mimeType="application/octet-stream")]
[Bindable]private var pngBytes:Class;
pdf.addImageStream( new pngBytes() as ByteArray,(pdf.getCurrentPage().w-50)/2,50);
·    addImage()
The addImage method takes an incoming DisplayObject. A JPG snapshot is done and included in the PDF document
pdf.addImage(vboxId,0,10);
4.    Print DataGrid
·    addGrid()
AddGrid() will allow you to pass any ArrayCollection and let AlivePDF inject the data in the PDF as a nice table. This new feature is available through the addGrid method which is receiving a Grid object and a position. You can set options like colors and alternate row colors, or text alignement in cells.
var myPDF:PDF = new PDF( Orientation.LANDSCAPE, Unit.MM, Size.A4 );
var gridColumnArtist:GridColumn = new GridColumn("Artist Name", "Artist", 40, Align.CENTER, Align.LEFT);
var gridColumnAlbum:GridColumn = new GridColumn("Album", "Album", 60, Align.CENTER, Align.LEFT);
var gridColumnPrice:GridColumn = new GridColumn("Price", "Price", 25, Align.CENTER, Align.LEFT);
var gridColumnInStock:GridColumn = new GridColumn("InStock", "InStock", 30, Align.CENTER, Align.LEFT);
var gridColumnMail:GridColumn = new GridColumn("E-Mail", "Mail", 60, Align.CENTER, Align.LEFT);
var gridColumnCell:GridColumn = new GridColumn("Cell Phone", "Cell", 30, Align.CENTER, Align.LEFT);

// create a columns Array
// it determines the order shown in the PDF
var columns:Array = new Array ( gridColumnArtist, gridColumnAlbum, gridColumnPrice, gridColumnPrice, gridColumnInStock,gridColumnMail,gridColumnCell);
// create a Grid object as usual
var grid:Grid = new Grid(dp, 200, 120, new RGBColor (0x666666), new RGBColor (0xCCCCCC), new RGBColor (0), true, new RGBColor ( 0x0 ), Joint.MITER );
// pass the columns
grid.columns = columns;
myPDF.addPage();
myPDF.textStyle( new RGBColor(0), 1 );
myPDF.setFont ( FontFamily.ARIAL, Style.NORMAL, 12 );
myPDF.addGrid( grid, 0, 5 );

另外对于Java,PHP和CS三种语言都提供后台生成文件

servlet文件下载

  评论这张
 
阅读(5034)| 评论(13)
推荐 转载

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017