Using DOMPDF to generate PDF’s with PHP

Saber Commerce uses DOMPDF a library for generating PDF’s. Like several other modern PDF generation libraries DOMPDF is capable of “reading and parsing HTML and CSS” in order to create the PDF output. This is (usually) preferable to having to specify the entire layout using PHP code which is how many earlier libraries would work. Generally speaking creating PDF’s has often been cumbersome in that there can be a lot of gotcha’s when specifying document layouts using code. Using the familiar HTML/CSS helps developers create PDF’s that are consistent with layouts on the web or in their applications.

There is some similarity in making PDF layouts to making email templates. Basically you have to consider that the support for a lot of modern CSS just isn’t available (yet). So keep the HTML and CSS simple and you’ll be fine. So instead of modern grids for instance, consider using basic HTML tables.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *