Introducing AlivePDF!

I'm currently working on a complete open-source AS3 PDF API called "Alive PDF".

This API will let you generate PDF with AS3 in a few easy steps, you'll be able to create a PDF document, add as many pages as you want and include images, sounds, and more to your pdf. A drawing API is also available to draw vectors and text in the PDF. This open new possibilites to online flash and AIR applications.

Tagging features are also supported and more to come ! :)

I will release documentation and sources as soon as possible, you can try a live demo at the bottom of this post :)

To generate a new PDF Document, you would do :

// create starting document
var myPDFEncoder:PDF = new PDF ( Orientation.PORTRAIT, Unit.MM, Size.A4 );
// add a new page
myPDFEncoder.addPage();
// this will add a snapshot of the canvas Sprite in the PDF with a JPG Compression
// compression level is set to 100 here
myPDFEncoder.addImage (canvas, null , true, ImageFormat.JPG, 100);
// save the pdf
myPDFEncoder.savePDF ( Method.REMOTE, "http://localhost/pdf/create.php", Download.ATTACHMENT, "myPDF.pdf" );

Thanks to Leonardo for the smooth logo ;)

Update : 26/06/07

I'm currently adding a full drawing API in Alive PDF. I tried to include an API very near from the flash.display.Graphics drawing API, even the native flash.display.CapsStyle and flash.display.JointStyle classes can be used to specify strokes styles. You can specify a dashed pattern to draw lines with the org.drawing.DashedLine class.

Here is a little preview of how it works :

// create starting document
var myPDFEncoder:PDF = new PDF ( Orientation.PORTRAIT, Unit.MM, Size.A4 );
// add a page
myPDFEncoder.addPage();
// specify line style
myPDFEncoder.lineStyle ( new RGBColor ( Math.random()*255, Math.random()*255, Math.random()*255 ), 1, .3, null, CapsStyle.ROUND, JointStyle.MITER);
// make it filled
myPDFEncoder.beginFill (  new RGBColor ( 0998, 0xFF, 0x00 ) );
// draw a rectangle
myPDFEncoder.drawRect (new Rectangle ( 20, 20, 50, 50 ));
// end the fill
myPDFEncoder.endFill ( );
// specify line style
myPDFEncoder.lineStyle ( new CMYKColor ( 0, 0, 0, 50 ), 1, .3, null, CapsStyle.ROUND, JointStyle.MITER);
myPDFEncoder.moveTo ( 90, 20 );
myPDFEncoder.lineTo ( 120, 80 );
myPDFEncoder.lineTo ( 200, 20 );
myPDFEncoder.lineTo ( 100, 10 );
// end the stroke
myPDFEncoder.end();
//save the pdf
myPDFEncoder.savePDF ( Method.REMOTE, "http://localhost/pdf/create.php", Download.ATTACHMENT, "myPDF.pdf" );

Online Demo :

A Flash animation should have appeared here, but it seems that your browser has an older version of the Flash Player or it is not installed at all. Please, install the last release of the Flash Player now, then reload this page.

Comments (43)

  1. Jon B wrote:

    This is fantastic – is this just for bitmapData at the moment or is there any thoughts towards embedding other data in the output pdfs – vector maybe – or you could do something really clever and get the swf to embed a swf into the pdf – then you could probably embed video and music and vector graphics. Not sure why you’d want to – but it could be pretty funky

    Friday, June 22, 2007 at 2:37 am #
  2. Hey, this is a very cool project i must say. At the moment i’m working on a Flex app to specify form layout used in PDF generation. I planned it to make it generate XML that Apache FOP can parse. Having the possibility to do it in flash would be awesome, and make my WYSIWYG view much more accurate.

    Have you ever heard about the haXe programming language (done by the author of the MTASC compiler)?

    I would be really excited if you’d give it a try (it supports AS3 api, and generates Flash(6-9) SWF, Javascript and Neko(Serverside tech/Desktop apps).

    Please take a look at http://www.haxe.org because you could probably use the same PDF generation code in at least the Flash and Neko platform!

    Talking about Adobe AIR, a similar (open source haxe) project allready exists for a few years called SWHX.

    Friday, June 22, 2007 at 3:55 am #
  3. Leonardo Braga wrote:

    Hello Thibault,
    Please check you gmail for a AlivePDF logo proposal… It’s just a suggestion, ok? :D
    Thanks.

    Friday, June 22, 2007 at 9:11 am #
  4. Thibault Imbert wrote:

    Hi Jon B,

    yes a drawing API is available to draw vectors in the PDF, like this :

    myPDFEncoder.moveTo()
    myPDFEncoder.lineTo()
    myPDFEncoder.drawRect()
    etc..

    Embedding the SWF is possible, I will check that yes, good idea !

    cheers ;)

    Friday, June 22, 2007 at 9:15 am #
  5. Nick wrote:

    Great stuff!

    Does it currently support CMYK as well as RGB colour modes? Any plans to introduce PDF form functionality? This would be ideal for things like personlised stationery generation.

    Keep up the good work.

    Friday, June 22, 2007 at 11:09 am #
  6. The ability to generate PDF’s without setting up a server-side tool is great! We do lots of educational projects here and this way we could let kids keep a resultsheet or certificate to print later.

    Any idea when you’re gonna have the first public beta or final?

    Friday, June 22, 2007 at 2:18 pm #
  7. Thibault Imbert wrote:

    Hi Michiel,

    I think the first beta will be available in a few weeks, I would say early July :)

    Friday, June 22, 2007 at 2:37 pm #
  8. Wow, that is pretty awesome! I’m looking for a solution for managing PDF forms, ideally in AIR so this could be very useful.

    Excellent work!

    Friday, June 22, 2007 at 4:10 pm #
  9. Tom wrote:

    This would be really handy. I guess just another output method like saving a JPG…but can this make a PDF with selectable text?

    Would be very handy to use along with a web app to make flow charts, invoices, etc. available in a format that many people use.

    Friday, June 22, 2007 at 6:05 pm #
  10. hosey wrote:

    I have some old AS1 code that translated html to pdf. If your want I could write it to work with your PDF creation. It makes things like Datagrid to pdf easier for people

    Friday, June 22, 2007 at 8:48 pm #
  11. Goach wrote:

    bon boulot, c’est le genre de fonctionnalités qui sera très demandés !

    Impatient de voir la suite…. :)

    Saturday, June 23, 2007 at 12:41 pm #
  12. pim wrote:

    Little problem with accents and special characters ..

    Monday, June 25, 2007 at 12:46 pm #
  13. Thibault Imbert wrote:

    Hi,

    Thanks pim for the bug, I will fix that ;)

    Monday, June 25, 2007 at 1:18 pm #
  14. this is sick! yew just keep pumping them out dont yew? i dunno. i

    Monday, June 25, 2007 at 8:20 pm #
  15. Pixelmixer wrote:

    Cant wait for the source. I’m actually very interested in your new drawing API. I’ve seen the Raster.as drawing class you have, but its not very flexible in its current state.

    Thursday, June 28, 2007 at 8:19 am #
  16. Rafeo wrote:

    Is it real! En la torre, nunca pensé que esto fuera posible!.

    Thursday, June 28, 2007 at 11:48 pm #
  17. Matthew wrote:

    I WILL be using this in an upcoming AIR application.. can’t wait!

    Monday, July 2, 2007 at 10:06 pm #
  18. aidee wrote:

    Great initiative! I’m migrating across from Java and one bugbear in Flex/AS was the lack of a similar framework like Pentaho on the Java side. Will there also be a similar tool like the Pentaho Report Designer for those designing forms that form the basis of the PDF export? I guess a MXML may suffice in this regard…

    Thursday, July 5, 2007 at 9:38 am #
  19. seth wrote:

    Awesome. Any plans for the reverse functionality? ie. PDF to a flash 9 swf. We’re currently using the swftools pdf2swf generator but that only creates an avm1 swf…

    best,
    Seth

    Saturday, July 7, 2007 at 2:26 am #
  20. Thibault Imbert wrote:

    hi seth,

    not for the moment, now I’d like to finish the first version then It could be interesting to work on the reverse functionality :)

    regards ;)

    Monday, July 9, 2007 at 1:49 am #
  21. share2 wrote:

    a very nice project

    Tuesday, July 10, 2007 at 10:53 am #
  22. Geert wrote:

    Great stuff!!
    Do you have a release date yet?
    Can’t wait to try it out!

    Thursday, July 12, 2007 at 7:59 pm #
  23. dundd wrote:

    Nice project!!!
    This will be helpful for everyone developing reports and so on. I am also playing around with this topic for some weeks, specially with XML and Apache FOP 0.93, but a real working PDF API in AS3 would be so fine. Can’t wait until the “source-day” ;-)

    Wish you all the best

    Friday, July 13, 2007 at 7:39 am #
  24. Jonathan wrote:

    In addition to embedding a swf file into the pdf, It would be nice to have a data set attached to the swf. This way you can manipulate data and then create a pdf graphical report.

    Friday, July 13, 2007 at 9:04 am #
  25. jon wrote:

    is there going to be a release this week?

    Wednesday, August 22, 2007 at 5:04 pm #
  26. Michael wrote:

    Is php required for making the download possible from flash player? I see you make reference to ‘http://localhost/pdf/create.php’. In other words, if you don’t have server side scripting, could you still initiate a download?

    Saturday, November 3, 2007 at 12:53 am #
  27. Adaś Wąmaś wrote:

    Hi!
    It’s realy great, but how can i use my own fonts with encoding in PDF?

    Friday, November 9, 2007 at 10:55 pm #
  28. Thibault Imbert wrote:

    Hi Adaś,

    This feature will be added in the next release 0.1.4, stay tuned !

    Saturday, November 10, 2007 at 12:32 am #
  29. Veer wrote:

    Hi!
    It’s really great…

    Fantastic done……

    It’s very helpful….

    thnks…..

    Monday, November 19, 2007 at 12:43 pm #
  30. Shardul Bartwal wrote:

    Really a nice feature,so need to write any code at the server end,its really super……

    Shardul Singh Bartwal

    Wednesday, January 16, 2008 at 11:17 am #
  31. chazzuka wrote:

    Excellent :) thank you for this, you rock!

    Thursday, March 27, 2008 at 3:32 pm #
  32. Michael D. wrote:

    C’est hard core qu’en meme à utiliser pour un novice :)

    Je cherche une methode pour transformer un pdf en plusieurs jpg, si une personne connait ça, merci de m’écrire un petit mail ;)

    Wednesday, May 21, 2008 at 11:46 pm #
  33. ramu.p@hcl.in wrote:

    Amazing, Thx for all your efforts :)

    Monday, September 8, 2008 at 12:28 pm #
  34. Brian Warner wrote:

    We have a client’s app that today is ASP.Net. We have already rewritten parts of the app using FLEX Builder 3. We are well on our way for all the internal tools, but have one issue where the original designer rendered PDFs using Crystal Reports and now the customers all use it to save the generated PDFs. We could always generate the PDF in the background using Crystal and then provide a link within FLEX, but we really want to directly render it. Do you have any ideas? Thanks,

    Brian Warner

    Friday, October 31, 2008 at 12:06 am #
  35. Nadeem wrote:

    Hi guys..i have been using this Alive PDF…and to some extend happy with that..but at the same time i’m having problem in generating multipage PDF..please suggest me how to convert datagrid results which are coming in more than one pages…i want to convert all into multi page PDf..please help…me..thnkx a lot..

    Friday, February 27, 2009 at 9:59 am #
  36. Thibault Imbert wrote:

    Hi Nadeem,

    You can use the new dynamic grid feature added in AlivePDF 0.1.4.8 :

    http://alivepdf.bytearray.org/?p=118

    Just pass any DataGrid DataProvider and it will automatically inject the data as nice formatted table on multi pages if needed.

    Thibault

    Friday, February 27, 2009 at 12:08 pm #
  37. Geetha Narayan wrote:

    IS there a way that i could get the flex chart in an mxml to a pdf using alive pdf? please please please i need help…

    Thanks,
    Geetha

    Thursday, September 24, 2009 at 8:13 pm #
  38. simar wrote:

    Hi,

    I want to convert one of my display object (that is created dynamically and use swc and graphics to draw other controls) into PDF.
    I used AlivePDF to achieve this and use pdf.addImage() method to add display object into this and i need this resulted PDF in vector format but it creates an image in PDF.
    so all Vector data is gone. I hope there will be a solution for this.

    Please reply me ASAP to achieve this using AlivePDF. It will be a great help for me.

    Very Thanks,

    Thursday, December 3, 2009 at 3:25 pm #
  39. sivakami wrote:

    Hi, Where can i find the documentation for alive pdf.

    Wednesday, April 21, 2010 at 2:06 pm #
  40. Raaz wrote:

    I have a big image when i export it one page only exporting after that the content is not able to view please help me if anybody have any solution

    Thursday, April 22, 2010 at 2:06 pm #
  41. jason wrote:

    I’m trying to merge more than 1 pdf into 1, not create the existing pdfs, I just want to merge multiple pdfs into 1. Can this be done with this library?

    Tuesday, May 11, 2010 at 7:59 pm #
  42. usman wrote:

    its nice jobs. but anyone who have any solution to export Advance DataGrid to pdf…

    Friday, August 20, 2010 at 8:52 am #
  43. Rajesh wrote:

    is there any generator to make .swf file from different images!
    pleas help me… thanks in advance.

    Saturday, September 17, 2011 at 12:03 pm #

Trackbacks/Pingbacks (6)

  1. Dando la chapa » Alive PDF on Friday, June 22, 2007 at 2:42 pm

    [...] Me parece a mi que AS3 le va a quitar el trabajo a algunos y dárselo a otros. Mr Thibault Imbert ha creado unas librerias AS3 para crear PDFs directamente desde Flash: Alive PDF. Pero es que este hombre ha creado tambien librerías para crear GIFs, leer GIFs, crear JPGs, mouse gestures, … echadle un ojo a su página de proyectos. [...]

     
  2. blog.2grafic.com » Blog Archive » Alive PDF on Friday, June 22, 2007 at 7:41 pm

    [...] Para ello utiliza un API AS3 PDF llamado “Alive PDF“. [...]

     
  3. flashblog » Blog Archive » alive pdf on Monday, June 25, 2007 at 2:57 pm

    [...] [...]

     
  4. Codexperimentz » Blog Archive » Alive PDF on Wednesday, July 18, 2007 at 3:04 am

    [...] I came across this post at rockonflash . Thibault Imbert is currently working on a complete open-source AS3 PDF API called “Alive PDF”. He is also known for his project wiiflash.org. try Alive PDF version. [...]

     
  5. More about AlivePDF - ByteArray.org on Wednesday, August 11, 2010 at 6:37 pm

    [...] I told you the other day, I added a full drawing API into AlivePDF, now we got a cool API that works exactly as the Flash [...]

     
  6. *drawlogic » AS3 Flash9 Commodore 64 Emulator *drawlogic on Sunday, December 19, 2010 at 7:39 am

    [...] the suport of binary ByteArray and/or BinarySockets AS3 has been inspiring all kinds of things from PDF creators, to audio, to JPEG Encoders, to zip libraries, crypto libraries and many others. But you know that [...]