What hqf-pdf Creates

Whole documents — invoices, delivery notes, payslips, contracts — and a small example for every feature they are built from, each creating a real PDF.

Every example comes with its code, written twice over: the same document once in Rust and once in Python. Most have a third button as well: the same document in JSON, the form sent to the service.

What Each Family Is For View the PDFs hqf-pdf Created See Why the Files Are Twice as Light Most of the Time, Often Far More, and up to Twelve Times Lighter

Complete business documents

The documents a business sends out every day, created by the software that already holds the figures. What this is for

A Payslip

A payslip: eighteen contribution lines, with the employee's share and the employer's, and for each the month's amount then the total since January. Each figure is tied to the line and the column it stands under, for software that reads the page aloud.

Read the source in: Rust Python JSON

A Tender Pack of Three Lots

Three lots, each attached to the document as a separate file, described by the columns the document defines itself — lot, day sent, amount — and sorted newest first. The cover page repeats the same columns in plain view, for reading software that does not show attached files.

Read the source in: Rust Python JSON

The Technical Detail

The examples above are whole documents. Those that follow are sorted by subject: each family shows a single thing a page can hold — a table, a barcode, a signature — with the program that creates it, so that the developer who uses this library can see exactly how it is done.

Pages, text and fonts

The page itself, the words on it, and the font — carried inside the file so the page looks the same everywhere. What this is for

Paragraphs, columns and typography

You supply the text; the library works out where each line ends, where each column stops and where each page breaks. What this is for

Paragraph Indents and Spacing

The same two paragraphs six ways: as they come, a first line pushed in, a first line pulled out, the room above and below, a justified block whose last line is centred, and where the first and last lines sit in their rectangle. A second page sets them four more ways: two other rules for the first and last lines, letters only outlined, and letters thickened by a line round them.

Read the source in: Rust Python JSON

Tabs and Tab Stops

The same tabulated rows under each of the three methods, then a contents block whose dots run out to a stop on the right. A tabulation can step on from wherever the text stopped, land on the regular grid of a typewriter, or aim at a stop of its own, on which the text that follows starts, centres, or lines up by its decimal point.

Read the source in: Rust Python JSON

Tables

Tables that fit their columns to the content, split across pages and repeat the heading row on each new page. What this is for

A Self-Paginating Table

A long table handed over whole, deciding for itself where the pages break: its heading on top of every page, its footnote under every page, a quarter's cell spanning its rows and written again at the top of the next page when a page cuts it, and a note you draw under each page at the exact place the table reports.

Read the source in: Rust Python JSON

Pictures inside Table Cells

A catalogue whose first column is a picture rather than text: four pictures of very different sizes and proportions, each fitted whole and undistorted into the cell the table gives it and standing against a different corner of it, claiming no width from its column and no height from its row.

Read the source in: Rust Python JSON

A Page and a Stamp inside Table Cells

A checking page for a pack somebody else sent: every row shows one of its pages, taken whole out of the file it arrived in, beside a stamp drawn once and placed in every row that was given it. Both are fitted to the cell the table leaves them, claiming no width from their column and no height from their row.

Read the source in: Rust Python JSON

A Timetable That Reports on Its Own Layout

A bus timetable with every cell outlined and a note on each saying why it is the size it is, the widths of its columns and the heights of its rows explained; then a table laid out despite its faults, a row cut across two boxes, spare room shared among rows, a table too wide for its box shrunk whole into it, and one notice running from cell to cell down a column, then through the two cells of a row.

Read the source in: Rust Python

Colour, inks and printing

The colour you set is the colour that goes to the press, and the printing works takes the file as it stands. What this is for

Grey, Screen and Printing Colours

Swatches in each of the three ways to say a colour — a grey as one number, a screen colour as three, a printing colour as four inks — each captioned with the instruction actually written into the file, and one mid-grey said four ways, the last as the hexadecimal code a screen designer hands over.

Read the source in: Rust Python JSON

A Sheet as It Goes to the Press

One drawing on four pages: a press sheet stating where the ink runs, where the blade falls and what is worth keeping, with trim marks; the same sheet cropped to the finished page; a landscape page that states a quarter turn clockwise on an upright sheet; and the first sheet again as the right half of a press sheet two pages wide.

Read the source in: Rust Python JSON

A Sheet Prepared for the Printing Works

One sheet larger than the finished page: the colour runs three millimetres past the blade, the trim marks stand outside it in an ink every plate carries, every colour is said in the four printing inks, and the page names the paper, the edge of the ink and the cut. Hand it the profile of a press and it claims PDF/X-4, and the sheet prints on itself which profile it is standing on.

Read the source in: Rust Python JSON

The Same Numbers, Said so They Mean Something

Six colours and a grey ramp painted three times over with the very same numbers: first left to the device, then said in two ways that state the white they are measured against, the curve applied to them, and how far the base colours reach. A second page paints bare numbers that say nothing about what they mean, and lets the page itself say it for them. All of that travels in a handful of numbers, with no profile to carry.

Read the source in: Rust Python JSON

One Rule Instead of a Hundred Colours

Four ways of writing down the rule a colour follows rather than the colours themselves: measured colours read off a table, a range cut into flat bands, one printing ink shown on a screen, and two rules joined end to end. Two more pages give every operation such a rule can use a grey strip of its own, then store one table at every precision, from black and white only to the finest.

Read the source in: Rust Python JSON

Drawing, patterns and transparency

Lines, shapes, gradients and transparency drawn as instructions in the file, not as pixels — sharp at any size, and weighing almost nothing. What this is for

A Plan That Shows What Can Be Read

A land plan whose layers decide by themselves when to appear. A wide name stands over the plot while the plan is looked at whole, the fine wall figures come in once it is enlarged twice over, and the sentence under the plan is there in two languages, of which reading software shows the one it is set to.

Read the source in: Rust Python JSON

One Drawing, Placed Many Times

One badge built as a drawing and placed eight times, plus once at half size: the file carries the drawing once, however many times it is placed. A second page shows a badge that turns itself a quarter wherever it is placed, says what it is, and holds a file of its own: the guest list.

Read the source in: Rust Python JSON

Images

Photographs placed at the size and the position you choose, from the image files a camera or a scanner already produces. What this is for

A Picture Fitted into a Rectangle

One picture fitted into a rectangle of one size eight ways: three ways of sizing it, the same one stood in the top left corner with a 12-point inset, a quarter turn left, a quarter turn right, a turn of 20 degrees, and a left-to-right mirror — every panel drawing the picture at the place and the size the library worked out. A second page adds eight more: the picture at its own size, then twice as large and cut where it hangs over; shrunk only when it is too big; set at nine positions at once; placed a quarter of the way in and down; turned a half turn; and mirrored top to bottom.

Read the source in: Rust Python JSON

Barcodes and 2D codes

The codes a till, a warehouse scanner, a boarding gate or a phone reads, printed straight onto the document. What this is for

Forms, stamps and overlays

Boxes the person receiving the form fills in on screen, and your text laid over a template: a PDF file somebody else already created. What this is for

Archiving, accessibility and metadata

Documents that will still open decades from now, that a screen reader can read aloud, and that an accounting system can book without anyone retyping them. What this is for

A File That Explains Its Own Entries

A records office's reference, the department it came from, the date until which the document must be kept and its classification, carried inside a file an archive still accepts. No archiving rule knows what a keep-until date is, so each entry carries a description of itself, and that description is what makes a checker accept a fact you alone invented. A second page adds a loan record whose entries are a yes or no, a type of file, a person's name, a measurement and two web addresses, and gives that page a hidden record of its own.

Read the source in: Rust Python JSON