PDF Generation in Actionscript - AlivePDF

The ability to create PDF documents natively in Actionscript has been something I've been looking for for a while. During the early stages of the AIR program I was really hoping that it would be included in it, however that was not to be.

Today however, I found the AlivePDF project which is a Native Actionscript 3 library for generating PDF's. It is open source, and now released under the liberal MIT licence which means it can be used in any project of your liking - as long as you keep the attributions - which is definitely fair enough.

From my perspective it means that I can use the library for some open source projects as well as for projects which are not open source, but means I'll have more time to work on it.

I've only scratched the surface of the AlivePDF codebase but so far it seems to work really well - and should make it possible to generate professional output from Flex and AIR applications.

An example of how to generate a simple PDF:

pdf = new PDF();
pdf.setDisplayMode (Display.FULL_PAGE,Layout.SINGLE_PAGE);
pdf.addPage();
pdf.setFont( FontFamily.ARIAL );
pdf.addText("My absolutely positioned text",1,10);
pdf.setFont( FontFamily.ARIAL , "", 32);
pdf.writeText ( 20, "Some flowing text that will go across pages");   

//Save the pdf as a byte array //to send to server or use AIR to write to a local file var bytes:ByteArray = pdf.savePDF(Method.LOCAL);

Thanks Thibault for the great software and I look forward to using and hopefully contributing over the coming months.

Note: Please see updated entry on this - my first contribution to the codebase which covers rich text formatting of created pdfs

Cheers, Mark

Comments
BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.