Skip to Content

Quick and dirty PDF Reports for Plain Text Accounting - Part 2

Previously I wrote about how to generate PDF reports for Plain Text Accounting. The post was a tad on Org mode fanboy side in that it relies heavily on org-mode to generate the PDF.

If you are willing however to compromise somewhat in the looks department and don't mind a whiff of old school nostalgia then you can produce PDF reports even simpler.

First of you probably need to install a few tools:


is used to generate Postscript from the output of hledger.


will convert above Postscript to PDF.


unless your journal only contains ASCII you most likely need iconv as enscript predates Unicode and cannot handle it (yes it is that old). So we need to convert the hledger output to ISO-8859-1 for example.


Finally we will combine all resulting PDF files into one with the help of the PDF Toolkit.

The basic command to generate a single PDF report is as follows (again we'll use the demo.journal from the hledger web site):

$ hledger balancesheet -f demo.journal | \
	  iconv -c -f utf-8 -t ISO-8859-1 | \
	  enscript -b 'Balancesheet' -o - | \
	  ps2pdf - balancesheet.pdf

This generates a hledger report first, encodes it to ISO-8859-1, renders it as Postscript and finally converts the result to PDF and stores it in a file.

Now pack this into a Makefile to generate all the reports that you need for your financial statement.

ICONV=iconv -c -f utf-8 -t ISO-8859-1

REPORTS= incomestatement.pdf balancesheet.pdf register.pdf all_transactions.pdf

financial_statement.pdf: ${REPORTS}
	pdftk $^ cat output $@

incomestatement.pdf: ${JOURNAL}
	${LEDGER} incomestatement -f $< | ${ICONV} | enscript -b 'Incomestatement' -o - | ps2pdf - $@

balancesheet.pdf: ${JOURNAL}
	${LEDGER} balancesheet -f $< | ${ICONV}  | enscript -b 'Balancesheet' -o - | ps2pdf - $@

register.pdf: ${JOURNAL}
	${LEDGER} register Asset:Bank -w 91 -f $< | ${ICONV} | enscript -b 'Register' -o - | ps2pdf - $@

all_transactions.pdf: ${JOURNAL}
	${LEDGER} print -x -f $< | ${ICONV} | enscript -b 'All Transactions||Page $$% of $$=' -o - | ps2pdf - $@

.PHONY: clean
	rm -f ${REPORTS} financial_statement.pdf

The generated PDF looks decent enough. Maybe not for a glossy annual report but certainly good enough to hand over to your accountant for approval.