Expand description
Round-27 — Linearization Parameter Dictionary reader (ISO 32000-1 §F.2 + Annex F.3).
Round 9 added the writer-side emission of linearized (“Fast Web
View”) PDFs in crate::linearize; this module is the read-side
complement. The linearization parameter dictionary is the FIRST
indirect object in a linearized file (§F.3.3: “shall be entirely
contained within the first 1024 bytes of the PDF file”) and carries
the structural offsets a streaming reader needs to fetch + render
the first page without downloading the rest:
| Key | Type | Required | Meaning |
|---|---|---|---|
/Linearized | number | yes | Version number — always 1 for Annex F. |
/L | integer | yes | Total file length in bytes. |
/H | array | yes | Primary hint-stream [offset length] pair |
/O | integer | yes | Object number of the first page’s /Page dict. |
/E | integer | yes | Byte offset of the end of the first-page section. |
/N | integer | yes | Total page count in the document. |
/T | integer | yes | Byte offset of the main cross-reference section. |
Two design notes:
- Plain (non-linearized) files are NOT errors — the parser
returns
Ok(None)when the file’s first object isn’t a linearization parameter dictionary, so callers can branch on theOptionwithout a try/catch dance. - No
/Linearizedvalue coercion — the spec leaves the version as “a number” rather than fixing it at1. We surface the value verbatim (as anf64) so future versions parse without changes.
Scope: parse only. Hint-table decoding (Annex F.4 — the page-offset + shared-object + thumbnail + outline tables packed inside the hint stream) is out of scope; a downstream tool that actually streams the file from network would consume those, but the parameter dict alone is what tells a viewer the file is linearized and where the main xref lives. Hint-table decoders are a round-28+ follow-up.
Structs§
- Linearization
Params - Parsed
/Linearizedparameter dictionary per ISO 32000-1 §F.2.
Functions§
- parse_
linearization_ dict - Parse the linearization parameter dictionary, if present.