Blog of Raivo Laanemets

Stories about web development, freelancing and personal computers.

Invoice generator released

Somewhere around 2010-2011 I built an invoice generator using lots of XML. At that time I still thought that XML was awesome. Anyway, I have been using the generator for some time and actually do not consider replacing it yet. Today I cleaned up my old code, made it installable and uploaded to GitHub.

How it works

An XHTML file is generated from invoice data (XML) and invoice template (XSL) using the xsltproc utility. The generated markup is piped to wkhtmltopdf which generates the final PDF output.

Example invoice can be found from here. The PDF result is here.

Other than calculating the line totals and the grand total the generator is pretty dumb. But even that requires specific XSLT extensions.


There are some things I do not like about this generator:

  • XSLT tools mandate usage of "old" (X)HTML DOCTYPE declarations. Part of the problem is described in this StackOverflow thread.
  • Calculations, like calculating VAT, are hard. They require specific XSLT extensions and are very verbose.
  • Localization requires multiple copies of XSL stylesheet. Keeping them in sync is maintenance trouble.
  • Input is XML. JSON is much less verbose. But this is not the biggest issue as there is not much input data.

If I was to build a new invoice generator today, I would probably use some proper programming language and an HTML template library to generate the intermediate markup (skip the xslt step above) and then feed it into the wkhtmltopdf utility.


No comments have been added so far.

Email is not displayed anywhere.
URLs (max 3) starting with http:// or https:// can be used. Use @Name to mention someone.