Dusk Invoice

Generate PDF invoices using Cairo.

This project is a Dusk package that wraps Cairo to generate PDF invoices from a simple text file following a specific format.

The package isn't designed to be very configurable, but rather to have a source code simple enough that it can easily be adapted to your needs.

This code is available from Dusk OS' files folder or as a Git repository (without SSL) at:

git://git.duskos.org/dusk-invoice.git

Input format

The first 10 lines (separated by ASCII LF) of the input files have a fixed meaning.

Line 1 is the language selector. It can be en or fr and it selects the language of the fixed strings being printed in the output.

Line 2 is the date of the invoice. It's a free-form string.

Lines 3-6 are the "Bill From" lines.

Lines 7-10 are the "Bill To" lines.

The rest of the lines are the "item lines" and each line begins with a quantity, then unit price, then description.

Quantity and unit price fields are in "integer cents" format. For example, 142 means "1.42". Here's an example input file:

en
Jan 7 2024
Virgil Dupras
42 Forth Ave
Montreal, QC A1B 2C3
Canada
Jules Winnfield
123 Sunset Blvd
Inglewood, Las Vegas CA
USA
2000 10000 Introduction to programming (hours)
400000 30 Transportation (km)

Build and run

To build this project, you need:

Running make will download Dusk OS and compile the package using its Usermode. The end result in a standalone dkinvoice executable.

This executable reads input from standard input and spits its ouput to a file specified as argument. It can therefore be executed like this:

./dkinvoice result.pdf < myinput.txt