Breaking a paragraph up, and aligning it
A paragraph broken into lines, set four ways: left, right, centred, justified.
A public-domain English novel handed over as one stretch of paragraphs and laid out across fifty-two numbered pages, with the engine choosing every line break and every page break.
Most examples on this site are one page long, which says nothing about what happens when a document is long. This one takes the text of Lewis Carroll's Alice's Adventures in Wonderland, published in 1865, exactly as it stands — one long run of paragraphs, with no formatting and no chapter structure handed in — and writes the whole of it as a single PDF of fifty-two numbered pages.
Nothing in the program counts pages or measures a line. It keeps a running position down the page, asks how much of the current paragraph fits under it, draws that much, and opens a new page when nothing more will go. Everything else — where each line ends, where each page ends, how a justified line is spaced — is the engine's decision. The novel is in the public domain: its copyright has expired and it carries no condition on its use.
The same document is written twice, once in each language. Both files are shown in full, with the code coloured on the server, and can be copied in one click.
The document this example writes, ready to open.
This document weighs 202,447 bytes.
The team wrote this book after measuring the documents above, so there is no earlier figure to set beside it. See every document measured.
A paragraph broken into lines, set four ways: left, right, centred, justified.
A word too wide for its column: left whole, or cut to the edge.
A justified column set twice: the long words breaking at their soft hyphens with a hyphen shown, or left whole, and a figure a no-break space keeps together.
A justified column set twice: file paths and compounds running past the edge with no break points, then wrapping where a break after a slash or a hyphen is allowed.
One long passage poured into three columns, each fitting the lines its height allows and handing the rest to the next.
The same two paragraphs six ways: the indents, the room around a paragraph, its last line, its first line.