
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 :
Comments (43)
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
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.
Hello Thibault,
Please check you gmail for a AlivePDF logo proposal… It’s just a suggestion, ok?
Thanks.
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
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.
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?
Hi Michiel,
I think the first beta will be available in a few weeks, I would say early July
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!
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.
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
bon boulot, c’est le genre de fonctionnalités qui sera très demandés !
Impatient de voir la suite….
Little problem with accents and special characters ..
Hi,
Thanks pim for the bug, I will fix that
this is sick! yew just keep pumping them out dont yew? i dunno. i
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.
Is it real! En la torre, nunca pensé que esto fuera posible!.
I WILL be using this in an upcoming AIR application.. can’t wait!
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…
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
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
a very nice project
Great stuff!!
Do you have a release date yet?
Can’t wait to try it out!
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
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.
is there going to be a release this week?
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?
Hi!
It’s realy great, but how can i use my own fonts with encoding in PDF?
Hi Adaś,
This feature will be added in the next release 0.1.4, stay tuned !
Hi!
It’s really great…
Fantastic done……
It’s very helpful….
thnks…..
Really a nice feature,so need to write any code at the server end,its really super……
Shardul Singh Bartwal
Excellent
thank you for this, you rock!
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
Amazing, Thx for all your efforts
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
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..
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
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
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,
Hi, Where can i find the documentation for alive pdf.
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
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?
its nice jobs. but anyone who have any solution to export Advance DataGrid to pdf…
is there any generator to make .swf file from different images!
pleas help me… thanks in advance.
Trackbacks/Pingbacks (6)
[...] 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. [...]
[...] Para ello utiliza un API AS3 PDF llamado “Alive PDF“. [...]
[...] [...]
[...] 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. [...]
[...] 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 [...]
[...] 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 [...]