Archive for January, 2011

The problem with choice

Tried to find a HTML to PDF generator for PHP the last few days … not easy.
I first found much about TCPDF. From the results it looked quite promising.
As it turns out it was not so easy to just put in your HTML like on the webpage, and get a good looking PDF.
After some testing i searched for alternatives and found DOMPDF. The render results for my page were much better than before with tcpdf. But as i tried a newer version it broke my layout completely (To be exact, somewhere between r305 and r309 of dompdf).
That lead me to submit a bug report. On the reported bugs i found someone pointing to another html2pdf php library: MPDF
mpdf does render my HTML good, too. It also prints some textboxes in the documents that dompdf did not. It has some other oddies, but seems quite nice till now.

The conclusion:
I yet not know which engine to choose. Till now dompdf and mpdf did the best job for me. dompdf produces a pdf with size of 6kb whereas mpdf uses 69kb. YMMV with different HTML, so you are on your own.
There are so many HTML to PDF engines out there, that it is not easy to choose. Thats only 3 i tested, and there are some more out there like fpdf, pdflib …
One of them is better on some tags, the other is better with some other. I keep wondering why not some of the engines could unite. More developers could mean better results. Lets assume there are 10 engines out inventing 10 wheels at the same time … what a waste of time.


Leave a comment

%d bloggers like this: