The first page, shown while the rest arrives
Ask for the file to be written first page first, so somebody opening it from a link sees page one almost at once.
Summary
A PDF is written back to front: what says where each page begins sits at the very end of the file. Reading software therefore waits for the whole file before it can show anything, and on a four-hundred-page catalogue opened from a link that wait is seconds long. The same document can be written in another order, its first page and a table of where the others begin placed at the head, so page one appears while the rest is still arriving. The file is a little bigger and takes a little longer to write, and it holds exactly the same document.
Technically
Written at the top level of a request, under
"first_page_first"
first_page_first writes the file linearised: a hint dictionary at the head, the first page's objects and the resources it draws with gathered behind it, and the tables that say where every other page and every category of object begins. Reading software that understands it fetches the head by range request and renders page one; software that does not reads the file the ordinary way and loses nothing. Two ways of writing a file cannot be combined with it, and the engine refuses each rather than write a file that would not open: compression.object_streams, because a file written first page first states the byte offset of every object and an object gathered into a stream has none of its own, and protection, because what locks each object is derived from the number it carries and writing the first page first renumbers them.
Request schema
-
first_page_first— object, optional, absent by default. -
first_page_first.enabled— boolean, optional,trueby default. A request naming the block and saying nothing about it is written first page first, which is what it named the block for. Set tofalse, the file comes out in the ordinary order. -
Refused beside it:
protection, andcompressionstatingobject_streamstrue. Both refusals come from the engine, which says which of the two the file cannot hold.
A whole request that creates a PDF
{
"first_page_first": { "enabled": true },
"standard_fonts": [{ "name": "sans", "face": "helvetica" }],
"items": [
{
"type": "text",
"rect": { "llx": 60, "lly": 740, "urx": 535, "ury": 762 },
"content": ["Page one, while the rest is still arriving"],
"font": "sans",
"font_size": 14
}
]
}
What is drawn, and how it comes out
Everything that can be drawn on a page The file's weight and the time it takes Layers reading software shows or hides A name that stands for several layers at once A drawing made once, shown by a button The sets of layers reading software offers Layers reading software shows one of at a time
Where to go next
Every JSON key of a request, in one page The other forty-one settings of a request