write_pdf.py
The Python file of the “A Minimal PDF” example. Two identical pages that draw the structure of an invoice with lines and rectangles, without a word of text: the file is about a dozen kilobytes and embeds no font.
What This Example Is For
Open this one first. Two pages, identical, each carrying the bones of an invoice — a coloured band across the top, a frame around everything, and two dozen empty rectangles where the lines of a table would go — and not a word of text anywhere on either. That is the whole of what a document needs in order to exist: pages, and marks on them. There are two rather than one because putting the second in costs a single instruction, and that is worth seeing at the outset. Everything else shown on this site is built on top of this, never instead of it.
What This Example Shows
- A coloured band across the top of each page, and a frame round all.
- Two dozen empty rectangles, stacked, where a table's lines would go.
- Shapes and nothing but shapes, so the file carries no font at all.