Tuesday, November 22, 2016

Creating a proper PDF out of HTML

If you have ever wanted to generate a nicely looking, non-rasterized, PDF out of HTML, you probably know that's its hard to find a good library for that. So, I think I have something good for you - PhantomJS!PhantomJS seems to offer a great way to generate PDF documents out of HTML pages:


Here is an example:

https://phantomjscloud.com/api/browser/v2/a-demo-key-with-low-quota-per-ip-address/?request={url:%22http://www.jonathantneal.com/examples/invoice/%22,renderType:%22pdf%22}


That sample, and many others, can be found here:
https://phantomjscloud.com


Original thread discussing phantomjs as a means of generating PDF is here:
http://stackoverflow.com/questions/6896592/is-it-possible-to-save-html-page-as-pdf-using-javascript-or-jquery

Original command:

phantomjs.exe examples/rasterize.js sample.html sample.pdf

Even better option would be Webkit to PDF (the same core is used):

http://wkhtmltopdf.org/

No comments:

Post a Comment

Ubuntu 12.04, 14.04, 16.04 - auto start an app or script before login

To run a command or application at startup, even before the user has logged in, you can use this file: /etc/rc.local The commands entered...