A reader normally needs the end of a PDF before it can show anything, because the table and trailer are there. That is slow over a network. From PDF 1.2 a file can be linearized, which Acrobat calls “fast web view”: the objects of the first page come first, with a table for them, so the first page shows as soon as it arrives, and hint tables tell the reader where every other page’s objects are, so it can ask the server for just those bytes. A linearized file is still an ordinary PDF; a reader that ignores linearization reads it the usual way.
The linearization parameter dictionary
The first object in the file, right after the header, is a dictionary that marks the file as linearized. It must be wholly within the first 1,024 bytes and hold only direct values:
%PDF-1.4
%âãÏÓ
43 0 obj
<< /Linearized 1 /L 54567 /H [ 475 173 ] /O 45 /E 5437 /N 11 /T 52786 >>
endobj
| Key | Meaning |
|---|---|
Linearized | Required: the version of the linearized form, 1 |
L | Required: the length of the whole file in bytes. If it does not match, the file was changed since and is read as an ordinary PDF |
H | Required: the offset and length of the primary hint stream, and, if there is one, of the overflow hint stream |
O | Required: the object number of the first page’s page object |
E | Required: the offset of the end of the first page’s section |
N | Required: the number of pages |
T | Required: the offset of the white space before the first entry of the main cross-reference table, object 0’s |
P | The page number of the first page, counting from 0; default 0 |
The order of the parts
| Part | Holds |
|---|---|
| 1 | The header |
| 2 | The linearization parameter dictionary |
| 3 | The first-page cross-reference section and trailer |
| 4 | The catalog and the other document-level objects needed to open the file |
| 5 | The primary hint stream |
| 6 | The first page: its page object, then everything it uses (content, fonts, images), and the outline if the document opens with it |
| 7 | The other pages in order, each with the objects only it uses |
| 8 | Shared objects: those used by more than one page, but not by the first |
| 9 | Everything else: the page tree, thumbnails, the outline, threads, named destinations, the Info dictionary, forms, the structure tree |
| 10 | An optional overflow hint stream |
| 11 | The main cross-reference section and trailer, for parts 4 to 10 |
Parts 5 and 6 may be swapped. The first-page section (part 3) lists the objects of
parts 2 to 6 and is the one an ordinary reader meets last: its trailer’s
Prev points at the main section, and the file’s last
startxref points at it, at the top of the file. Its trailer has
Size for the whole file, so the two sections read together as if the
file had been updated once. The objects of the first page take the highest object
numbers, so that they sit in one subsection.
xref
43 14
0000000052 00000 n
…
trailer
<< /Size 57 /Info 41 0 R /Root 44 0 R /Prev 52776 /ID [<…><…>] >>
startxref
0
%%EOF
startxref 0 is allowed here, because a linearized reader finds the table from the dictionaryHint streams
The primary hint stream is an ordinary stream object whose data is several hint tables, one after another. The stream dictionary gives the offset of each table in the data, except the page offset table, which is always first, at offset 0:
| Key | Since | Table |
|---|---|---|
| none | 1.2 | Page offset hint table, required, at offset 0 |
S | 1.2 | Shared object hint table, required |
T | 1.2 | Thumbnail hint table, if there are thumbnails |
O | 1.2 | Outline hint table, if there is an outline |
A | 1.2 | Thread information hint table |
E | 1.2 | Named destination hint table |
V | 1.2 | Interactive form hint table |
I | 1.2 | Information dictionary hint table |
C | 1.3 | Logical structure hint table |
L | 1.3 | Page label hint table |
Hint tables are bit streams, high bit first, and each starts on a byte boundary. Most fields are written as a difference from a least value given in the table’s header, in as few bits as the header says, so that a table for hundreds of pages stays small. Offsets in hint tables do not count the hint stream itself: a reader adds the primary hint stream’s length to any offset beyond it.
The page offset hint table
A header, then one entry for each page. Header:
| Item | Bits | Meaning |
|---|---|---|
| 1 | 32 | The least number of objects in a page, the page object included |
| 2 | 32 | The offset of the first page’s page object |
| 3 | 16 | Bits needed for the difference between the most and least objects in a page |
| 4 | 32 | The least length of a page in bytes |
| 5 | 16 | Bits needed for the difference in page length |
| 6 | 32 | The least offset of a content stream from the start of its page |
| 7 | 16 | Bits needed for the difference in that offset |
| 8 | 32 | The least length of a content stream |
| 9 | 16 | Bits needed for the difference in content stream length |
| 10 | 16 | Bits needed for the most shared object references of a page |
| 11 | 16 | Bits needed for the largest shared object identifier |
| 12 | 16 | Bits needed for the numerator of a shared object’s position in the content |
| 13 | 16 | The denominator of that fraction |
Then, for each page, these items, each in the number of bits the header gives:
| Item | Bits (header item) | Meaning |
|---|---|---|
| 1 | 3 | Objects in the page, minus the least |
| 2 | 5 | The page’s length, minus the least |
| 3 | 10 | How many shared objects the page uses; 0 for the first page |
| 4 | 11 | For each of those: its index in the shared object hint table |
| 5 | 12 | For each of those: how far into the content stream it is first needed, as a fraction of the denominator |
| 6 | 7 | The content stream’s offset from the page’s start, minus the least |
| 7 | 9 | The content stream’s length, minus the least |
The items are not written page by page but item by item: item 1 for every page,
then item 2 for every page, and so on, items 4 and 5 for pages 2 onwards. A page’s
offset is the first page’s plus the lengths of the pages before it; its objects are
numbered in a run from the first page’s O for page 1, and from 1 for
the rest, in page order.
The other hint tables
The thumbnail table has a header of 12 items (the first thumbnail’s object number and offset, how many pages have one, least lengths and object counts, and the thumbnails’ shared objects) and an entry for each page. The outline, thread, named destination, Info and page label tables are generic: four 32-bit numbers, the first object’s number and offset, the number of objects and their length. The form and logical structure tables are extended generic: the same four, then the number of shared objects they use, a 16-bit bit count, and their shared object indices.
Checking a linearized file
- The first object after the header has
Linearized, andLequals the file’s length. If not, the file has been updated or damaged and should be read as an ordinary PDF. - Any incremental update appended later breaks the linearization, though the file stays readable.
- Hint tables written by some programs are wrong; readers use them only as hints, and fall back on the cross-reference table.