Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Convert HTML to PDF in PHP (libwkhtmltox extension) (perplexedlabs.com)
20 points by matticakes on Sept 15, 2010 | hide | past | favorite | 6 comments


Man, I LOVE wkhtmltopdf. It's an excellent, quick-n-dirty way to get your site into a PDF. There's some caveats, though:

- Want to do columns? You're screwed! It uses WebKit as the rendering engine, so any columns you specify will go WELL past the page break before they wrap, and looking HORRIFYIN'.

- If your fonts aren't set up perfectly, expect some super-ugly text (jaggies, etc).

- You will have to play with it for quite a while if you want to do anything fancy with headers, and you'll likely have to settle for something less ambitious than you started with.

- Have Unicode in your source HTML files? Hope you're comfortable with how that all works, or are cool with transliteralisation. Or cool with all kinds of #?^s through your files.

For anything heavy-duty, I'd recommend biting the bullet and using FPDF or a heavy-duty PDF creation library. But for quick and easy, wkhtmltopdf is excellent.


Sure, it's certainly not perfect. In the cases where I've used it the benefits far far outweigh the negatives you've pointed out.

I feel like you need to enter with an open mind for any conversion to PDF...


TCPDF might be another option (it's a fork of FPDF) - it has a decent HTML layout engine built in.


I wonder how the Nytimes front page will be converted.


Not bad (this done without specifying any options which might improve conversion)...

http://www.visionaryrenesis.com/nytimes.pdf


I have used MPDF given the limitations of the shared server I am using. But I would definitely give a try to your extension.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: