Generating Invoice PDFs

I need to generate PDF files for invoices. How hard can it be? My project is developed using PHP, so I first had a look at the available PDF libraries for PHP.


TCPDF is a project to generate PDF files from PHP. It is available since 2002 and is used in many projects. However, there are a few concerns:

  • The API is not object oriented, but uses one huge TCPDF class. It uses PHP constants for several configuration options and the API does not use constants, but strings.
  • Example: To create a new TCPDF object with the page format A4 and mm as units, you would use: new TCPDF(‘P’, ‘mm’, ‘A4’);
  • The biggest showstopper is that configuration for fonts takes place using PHP constants, which, once defined, cannot be changed. That means that it is very hard to integrate TCPDF into Symfony2.


ZendPDF is the PDF class from the Zend Framework. I have looked at ZendPDF Version 2. Given the repository activity on GitHub, it seems that ZendPDF is not really maintained and documentation is completely missing.


PhantomJS is a headless web browser based on WebKit, which can also be used to render the output of a HTML page to a file. Unfortunately, phantomjs has a serious kerning problem as seen here: Example PDF. The exact same issue occurs using wkhtmltopdf.


LaTeX is…well…LaTeX. Either you have it or you love it. In my case, the lack of experience with LaTeX and struggling for 2 hours implementing a proper footer placed LaTeX on the bottom of the priority list.

Web-based services

I had a look at several web-based invoicing solutions, including Sage One and Freshbooks. Sage One didn’t support downloading of invoice PDFs via the API, and Freshbooks wasn’t able to produce invoices switchable date formats per invoice.


Right now, my best bet is probably using LaTeX. I might update this post at a later point


  1. I had good experiences with fpdf, check that one out AS well.

  2. What about html2pdf? Like this one:

Add Comment Register

Leave a Comment

NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">