What linearization does to a PDF file
HTTP byte-range requests and linearization
Range: header). When a browser or PDF viewer requests a linearized PDF, the sequence is:
1. The viewer downloads the first portion of the file (typically a few kilobytes to tens of kilobytes) — enough to read the linearization dictionary and first-page xref.
2. The viewer parses the first-page xref, identifies the byte ranges of all first-page objects.
3. The viewer issues targeted HTTP Range: requests for those specific byte ranges.
4. Page 1 renders — often before the rest of the file has been fetched at all.
5. For subsequent pages, the viewer uses the hint tables to calculate the byte offset of any page and issues a targeted range request — without downloading pages it does not need.
For large PDFs (reports, presentations, manuals) accessed over typical internet connections, this can reduce time-to-first-render from tens of seconds to under a second. For small PDFs (under ~100 KB), the overhead of the linearization structures sometimes makes the linearized version slightly larger, and the latency savings are negligible since the whole file downloads quickly anyway.
PDF.js note — Mozilla's PDF.js (used in Firefox, and available as a web component) supports linearized PDF byte-range fetching when the server sends the Accept-Ranges: bytes response header and the PDF is linearized. Chrome's built-in PDF viewer also uses range requests for linearized PDFs.Creating linearized PDFs
-dFastWebView=true flag:
gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dFastWebView=true -sOutputFile=output.pdf input.pdf
qpdf — The qpdf command-line tool has a dedicated linearize option:
qpdf --linearize input.pdf output.pdf
qpdf is reliable, open-source, and available via most package managers (apt install qpdf, brew install qpdf).
PDF libraries — Apache PDFBox supports linearization via its PDFMergerUtility with the linearize method. iText's commercial tier supports linearization. pdf-lib (JavaScript) does not currently support linearization output — the output is valid PDF but not linearized.
Critical caveat: linearization is destroyed by editing — If you open a linearized PDF in a tool and save it with incremental updates, the incremental structure appended to the end of the file breaks linearization. The file must be fully rebuilt (saved with linearization) after any structural change. Verify linearization state after any PDF processing step in your pipeline.Verifying linearization
qpdf --check input.pdf reports whether the PDF is linearized and whether the linearization is valid (since a PDF can claim to be linearized but have an invalid hint table or misaligned offsets).
Ghostscript — gs -dBATCH -dNOPAUSE -sDEVICE=nullpage -c "(input.pdf) (r) file runpdfbegin linearized? = quit" — outputs "true" or "false".
Text inspection — Open the PDF in a text editor (or run strings input.pdf | head -20). A linearized PDF has a linearization parameter dictionary near the very beginning: look for /Linearized 1 in the first few hundred bytes. A non-linearized PDF will not have this.
Adobe Acrobat Pro — File > Properties > Description tab — look for "Fast Web View: Yes" near the bottom of the dialog.
Chrome DevTools — Load the PDF URL in Chrome, open DevTools > Network, click the PDF request, and examine the request log. A linearized PDF served with Accept-Ranges: bytes will show multiple small range requests rather than a single large download.