Posts

Pdf Generation with PHP

The topic of PDF generation with PHP used to be quite painful : PHP native functions require PDF lib, a library that does not come straight out of the box, and is distributed under commercial license. In spite of this dominant position, other solutions have been implemented and available under opensource license.

  • fpdf is probably the most famous of PHP PDF libraries. FPDF project remained inactive for years but was still very usable in its latest version, dated 2004. And finally after 4 years of inactivity a new version finally came out this august 2008, with important features such as GIF image support and possibility to have different page formats in a single document. Most interesting is the additionnal PDFTable class, which does a very good job render HTML table conversion to PDF format. That's in my opinion the easiest way for a webmaster with good knowledge of  HTML to generate PDF documents.
  • TCPDF is another example of an advanced PHP PDF generation library but I haven't tried it yet. Does seem to support some level of HTML parsing but not to the point of converting HTML tables to PDF (see above)
  • ZendPDF is a good bet as a component of Zend Framework but focuses on low level graphic functions and as such lacks essential features such as automatic word wrapping.