I'm trying to convert XML data into PDF files from a web page and I was hoping I could do this entirely within Javascript. I need to be able to draw text, images and simple shapes. I would love to be able to do this entirely in the browser.
This is not possible without a plug-in in the browser or some server side coding.
There's already an Actionscript 3.0 open source library that can generate PDF's 100% client side.
http://alivepdf.bytearray.org/
In theory, it should be possible to do it in Javascript too, I think, but it seems rather complex.
If requiring flash is acceptable, you could probably write some glue AS code to take data from JS (sending it as JSON, for instance), and use the library to generate the PDF.
The bigger question here is are you not using a server-side technology? I really can't imagine a situation where it would be more feasible to implement a javascript implementation than just doing it on the server-side. Doing this in javascript would take a lot of work, would be far from perfect, and not very fast on older machines/browsers.
On the server, however, there's numerous open-source libraries and programs that can do the heavy lifting for you and cut down your development time. Like ghostscript for example.
Even if you could generate the PDF in-memory in JavaScript, you would still have the issue of how to transfer that data to the user. It's hard for JavaScript to just push a file at the user.
To get the file to the user, you would want to do a server submit in order to get the browser to bring up the save dialog.
With that said, it really isn't too hard to generate PDFs. Just read the spec.
I've just written a library called jsPDF which generates PDFs using Javascript alone. It's still very young, and I'll be adding features and bug fixes soon. Also got a few ideas for workarounds in browsers that do not support Data URIs. It's licensed under a liberal MIT license.
I came across this question before I started writing it and thought I'd come back and let you know :)