Skip to main content

Module pdf

Module pdf 

Source
Expand description

PDF export: display structure in, PDF bytes out.

The painter for print. Everything it needs already exists on the page — glyph ids, absolute positions, page trim — so this stage places what layout decided and decides nothing itself.

Glyphs are shown at their own x, not at the font’s: kerning and justification put them where they are, and a PDF that re-derived positions from advances would disagree with the preview. The text each run was shaped from travels with it, so the writer can build the glyph-to-character map that makes the text selectable.

Links and the outline are layout’s too: each link arrives on its page with the areas it covers and the place it goes, and each outline entry with the place of its heading.

Enums§

PadTo
The page count a print vendor asks a book to reach.
PdfError
What can go wrong turning the display structure into a PDF.

Functions§

page_count
How many pages write_padded writes for this book: the pages laid out, and the blank pages pad adds after them.
write
Writes one laid-out book as PDF bytes.
write_padded
The same, with blank pages after the last page until the book has the count pad names. page_count returns that count.