Welcome the company of trees

XSL-FO stylesheet for ledger

Mr. Fredrik Unger

Tree.se

2013-04-25

Abstract

In using the Ledger-cli software I had the need for nicely formatted reports for my accountant. There were some solutions but no really easy straight forward. I decided to try to use the xml output and create a pdf from that via XSL-FO style sheets.


Introduction

I have been a user of Docbook for quite some time and I decided to try to create a XSL-FO style sheet to bring the ledger-cli xml output to a more nicely formatted pdf. There are some other tools using tex but I did not get them to work well.

Prerequisites

To use this style sheet you need an xsl processor like xsltproc and a fo processor like fop. You also need a ledger that includes the commits 44823d241f01c9cb2b891283f9e110f15aeebf9a and a875940a93848d4b18b5bed45049edc901ad07a2 from 2013-03-08. Those were fixes to the xml export. You also need the ledger.xsl style sheet. I currently do not host it in a git or so. That might come if there is interest. Best would be if it got adopted upstream.

Usage


    ledger -f ledger.dat xml > sample.xml
    xsltproc ledger.xsl sample.xml > sample.fo
    fop sample.fo sample.pdf
    okular sample.pdf
  

Example

Using the current test/input/demo.ledger data in the ledger git one can generate several examples. There are probably still issues but for my simple needs, a simple ledger with a few currencies it works well. Comments and some other things are currently not considered.


      ledger -f test/input/demo.ledger xml > demo.xml
      xsltproc ledger.xsl demo.xml > demo.fo
      fop demo.fo demo.pdf
      okular demo.pdf
    

results in demo.pdf