dompdf is an HTML to PDF converter. At its heart, dompdf is (mostly) CSS2.1 compliant HTML layout and rendering engine written in PHP. It is a style-driven renderer: it will download and read external stylesheets, inline style tags, and the style attributes of individual HTML elements. It also supports most presentational HTML attributes.
PDF rendering is currently provided either by PDFLib (http://www.pdflib.com) or by a bundled version the R&OS CPDF class written by Wayne Munro (http://www.ros.co.nz/pdf). (Some performance related changes have been made to the R&OS class, however). In order to use PDFLib with dompdf, the PDFLib PECL extension is required. Using PDFLib improves performance and reduces the memory requirements of dompdf somewhat, while the R&OS CPDF class, though slightly slower, eliminates any dependencies on external PDF libraries.
Features
- handles most CSS2.1 properties, including @import, @media & @page rules
- supports most presentational HTML 4.0 attributes
- supports external stylesheets, either local or through http/ftp (via fopen-wrappers)
- supports complex tables, including row & column spans, separate & collapsed border models, individual cell styling, (no nested tables yet however)
- image support (gif, png & jpeg)
- no dependencies on external PDF libraries, thanks to the R&OS PDF class
- inline PHP support. See below for details.
Requirements
- PHP 5.0.0+
- Some fonts. PDFs internally support Helvetica, Times-Roman, Courier & Zapf-Dingbats, but if you wish to use other fonts you will need to install some fonts. dompdf supports the same fonts as the underlying R&OS PDF class: Type 1 (.pfb with the corresponding .afm) and TrueType (.ttf). At the minimum, you should probably have the Microsoft core fonts (now available at: http://corefonts.sourceforge.net/). See the INSTALL file for font installation instructions.
Limitations (Known Issues)
- tables can not be nested
- not particularly tolerant to poorly-formed HTML input (using Tidy first may help).
- large files can take a while to render
- ordered lists are currently not supported
You can follow http://www.twitter.com/ryanmasten for important DOMPDF updates.