A Big Document Whose First Page Shows Straight Away

You send a customer a 400-page catalogue. They click the link, and nothing happens for several seconds. They are not waiting for page 400 — they only wanted to look at page one. A document can be written so that page one appears almost at once and the rest keeps arriving behind it: the same document, written in another order.

What This Is Called

This is called linearising a PDF, and a file written that way is a linearised PDF — or linearized, spelled the American way, which is how you will most often meet it in a list of requirements. Some reading software calls the same thing Fast Web View, and shows it as a yes or a no in the document's properties.

Our engine writes linearised PDF. There is one option to turn on, and nothing else about the document changes.

What a linearised PDF is, in the glossary

Detail — 20 815 bytes instead of 1 201 870

One novel, carried whole, written twice: once the ordinary way, once first page first. Nothing else differs between the two files.

  • 1 201 870 bytes — must arrive before page one can be shown, on the file written the ordinary way — which is the whole of it.
  • 20 815 bytes — on the file written first page first.
  • 1 181 055 bytes — no longer waited for.

The reading software shows page one once the beginning of the file has arrived, instead of waiting for all of it.

The figures are read off the two files themselves, not typed in. The file you can download is that book written first page first — 357 pages, the last of them carrying these three figures — and what is measured is the book without that last page.

See the two files, and the program that wrote them

When it makes no difference

Worth knowing before you turn it on. The gain is felt only when the document is read as it arrives, and that needs two conditions.

  1. The server that hands the file over has to be able to send a slice of it on request. Most do, out of the box. A server that only ever sends whole files hands over the whole file, and the reading software waits for it like before.
  2. The reading software has to make use of it. The ones built into Chrome, Firefox and Edge do. So does Adobe Acrobat Reader. Some others read the file the ordinary way — and lose nothing at all doing so, because the document is the same document.

And there are two documents it cannot be asked of at all, which the engine says plainly rather than writing a file that would not open: one protected by a password, and one whose objects are packed together to save room. Both are explained under Technically below.

And it does nothing at all in the cases where nobody is waiting: a file attached to an email, a file copied to a shared folder, a file downloaded whole and opened afterwards. In all of those the document has already landed before anybody looks at it.

So: if your documents are opened from a link, turn it on. If they are sent as attachments, it changes nothing. Either way it adds nothing to the price: it is an option of the engine, not something sold beside it.

Technically

Linearisation in the sense of ISO 32000, clause 7.5.8: a first-page cross-reference section and the linearisation parameter dictionary at the head of the file, page one and its resources immediately after, then the remaining objects, then the main cross-reference section. The hint tables — the shared-object hint stream and the page-offset hint stream — let reading software work out the byte range of any page and ask for it in a single ranged request.

The figure above is the /E entry of the parameter dictionary, which states the offset of the end of the first page: everything before it is what reading software must hold before showing a page. A file written the ordinary way states nothing of the kind, so the answer for it is its own length. That is why the two numbers are comparable — one measurement, applied to two spellings of one document.

What to check at your end: the server must answer Accept-Ranges: bytes and honour Range requests with a 206, on the exact route that serves the documents — a front server placed in front, a compression layer applied on the fly, or a delivery network set to transform the body will each quietly turn ranged requests back into whole-file transfers. Content-encoded responses are the usual culprit: a PDF served under Content-Encoding: gzip cannot be range-requested meaningfully, and a PDF is already compressed inside, so serving it uncompressed is the right call anyway.

It composes with tagging, PDF/A and PDF/UA conformance, and signing. It is written last, over the finished document, so it never changes what the pages say.

Two things it cannot be asked for at once, and the engine says so rather than writing something that would not open: a document packed into object streams, because an object inside a stream is nowhere on its own and the head of the file has to say where each one is; and a locked document, because what locks an object is worked out from the number it carries, and writing the first page first is what changes those numbers.

Where to Look Next

The book that was measured, and its program What a linearised PDF is, in the glossary Changing the Library That Writes Your Documents The Engine inside Your Own Program

See the Prices See the Examples