Skip to main content

Module linearize

Module linearize 

Source
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:

KeyTypeRequiredMeaning
/LinearizednumberyesVersion number — always 1 for Annex F.
/LintegeryesTotal file length in bytes.
/HarrayyesPrimary hint-stream [offset length] pair
/OintegeryesObject number of the first page’s /Page dict.
/EintegeryesByte offset of the end of the first-page section.
/NintegeryesTotal page count in the document.
/TintegeryesByte 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 the Option without a try/catch dance.
  • No /Linearized value coercion — the spec leaves the version as “a number” rather than fixing it at 1. We surface the value verbatim (as an f64) 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§

LinearizationParams
Parsed /Linearized parameter dictionary per ISO 32000-1 §F.2.

Functions§

parse_linearization_dict
Parse the linearization parameter dictionary, if present.