Here's an again super rudimental example - click on the stage will invoke the "save file as..." dialogue. package { import flash.display.Sprite; import flash.events.MouseEvent; import flash.net.FileReference; import flash.utils.ByteArray; import org.alivepdf.fonts.CoreFont; import org.alivepdf.fonts.FontFamily; import org.alivepdf.fonts.IFont; import org.alivepdf.layout.Orientation; import org.alivepdf.layout.Size; import org.alivepdf.layout.Unit; import org.alivepdf.pdf.PDF; import org.alivepdf.saving.Download; import org.alivepdf.saving.Method; public class PDFDemo extends Sprite { private var _pdfByteArray:ByteArray; public function PDFDemo():void { var pdf:PDF = new PDF(Orientation.PORTRAIT, Unit.MM, Size.A4); var helvetica:IFont = new CoreFont(FontFamily.HELVETICA); pdf.addPage(); pdf.setFont(helvetica, 24); pdf.writeText(24, "Hello World!"); _pdfByteArray = pdf.save(Method.LOCAL, null, Download.ATTACHMENT); stage.addEventListener(MouseEvent.CLICK, click); } private function click(e:MouseEvent):void { new FileReference().save(_pdfByteArray, "hello-world!.pdf"); } } }
... View more