views:

385

answers:

5

I have some HTML that includes bolding, italics, small tag, big tag, blockquote tag, bullets, and numbered items. I need to convert it to PDF via PHP. I tried FPDF, but it was entirely too complex. I tried html2pdf PHP library, which uses FPDF, but it was very buggy and unreliable. What do you recommend?

Note: Imagine your typical resume. I'm needing to format something like that.

duplicate of http://stackoverflow.com/questions/265760/generating-pdfs-with-php

A: 

I've had a lot of success with dompdf.

Make sure you have valid HTML though, or it can get into a loop. It's very simple to use - about 4 lines to convert an HTML file to a PDF.

Greg
I heard that dompdf is nice, but takes 32+MB of RAM per request (a comment on Digg from someone). What have you found?
A: 

Take a look at FPDF

Sudden Def
A: 

I have had good experiences with PrinceXML. Their rendering engine is very good. Passes acid2 and has good .svg support so you can include vector images instead of bitmaps to keep the .PDF relatively small (which is important when generating reports which need to be sent as an attachment).

(note that princexml is proprietary software).

warpr
A: 

There is a similar question on SO here:

Philip Morton
A: 

http://www.ros.co.nz/pdf/

I once used the above to turn incredibly complex architect's tile specifications into PDFs on a dynamic basis and it worked out well. I found the class very approachable and easily modifiable.