PurePDF - 添加显示对象的高质量快照的最佳方式

时间:2013-09-01 19:46:26

标签: flex pdf

任何人都有使用PurePDF的经验并向页面添加显示对象?在AlivePDF中,你可以这样做:

pdfObject.addImage(yourDisplayObject,...)

其中yourDisplayObject是一个继承自DisplayObject的类。 AlivePDF内部负责将其转换为图像并将图像添加到pdf页面。

purePDF的等价物是什么?

那里有任何purePDF专家吗?

1 个答案:

答案 0 :(得分:0)

我使用的是PurePDF。这段代码将采用像UIComponent这样的对象,将其转换为位图并将其放在pdf中。

var matrix : Matrix = new Matrix();
var pageSize:RectangleElement = PageSize.A4;
var mainImage : BitmapData = new BitmapData(_objectToPrint.width,_objectToPrint.height,false, 0xFFFFFF);
mainImage.draw(_objectToPrint,matrix);

var bytes:ByteArray = new ByteArray();
var document:PdfDocument = PdfWriter.create(bytes, pageSize).pdfDocument;
document.setMargins(0,0,0,0);
document.open();
var imageElement : ImageElement = ImageElement.getBitmapDataInstance(mainImage, false);
document.add(imageElement);
document.close();
new FileReference().save(bytes,"yourPDF.pdf");