PDF Object Stream

A PDF Object Stream (stream type /ObjStm) is a compressed stream that bundles multiple indirect objects together inside a single PDF stream object. Introduced in PDF 1.5, object streams dramatically reduce file size when combined with cross-reference streams, and are commonly used in modern PDF generators and optimisers.

A PDF Object Stream (identified by the <code>/ObjStm</code> stream type) is a compressed stream object that bundles multiple indirect PDF objects together inside a single stream. Introduced in <a href="https://pdftheguide.com/news/pdf-version-history" target="_blank" rel="noopener">PDF 1.5</a>, object streams are one of the most effective tools for reducing the size of PDF files — particularly those with many small objects such as forms, annotations, or complex structure trees.

Before object streams, every indirect object in a PDF occupied its own discrete space in the file, individually indexed in the cross-reference table. Object streams allow many small objects to be stored together, compressed as a unit, and referenced through a <a href="https://pdftheguide.com/glossary/pdf-cross-reference-table" target="_blank" rel="noopener">cross-reference stream</a> — replacing the traditional ASCII xref table with a more compact binary structure.

Structure of an object stream

An object stream is a stream object whose <code>/Type</code> is <code>/ObjStm</code>. It has two key dictionary entries: - <code>/N</code>: The number of indirect objects stored in this stream. - <code>/First</code>: The byte offset from the start of the decoded stream to the first object body. The initial portion of the decoded stream (before <code>/First</code>) contains pairs of object numbers and byte offsets that act as a mini-index.

The stream data itself (after decompression, typically using FlateDecode/deflate) contains the serialised object bodies, one after another. Objects stored in an object stream are called <strong>compressed objects</strong>. Their file-level cross-reference entries use a special type (type 2) in the cross-reference stream, recording the object stream's object number and the index within the stream.

Certain objects cannot be stored in object streams: stream objects themselves (including content streams, image data, and other object streams), the document's encryption dictionary, and the document's cross-reference stream. Everything else — page dictionaries, annotation dictionaries, font descriptors, name trees, structure tree nodes — can be compressed into object streams.

Cross-reference streams

Object streams work in conjunction with cross-reference streams. PDF 1.5 replaced the traditional ASCII cross-reference table (<code>xref</code> keyword) with a binary <a href="https://pdftheguide.com/glossary/pdf-cross-reference-table" target="_blank" rel="noopener">cross-reference stream</a> that can itself be compressed using FlateDecode. This provides a second level of size reduction: not only are the objects compressed, but the index pointing to them is also compressed.

A cross-reference stream uses a compact binary entry format (typically 3-byte or 4-byte entries depending on the file size) instead of the fixed 20-byte ASCII entries of the traditional xref table. For large PDF files with thousands of objects, this alone can save tens of kilobytes.

PDF readers written for PDF 1.5+ must support both cross-reference streams and cross-reference tables, because a PDF may use either. PDF optimisation tools often convert traditional xref tables to cross-reference streams as part of their optimisation pass.

Size reduction in practice

The size reduction from object streams varies by document type:

- **Tagged accessibility PDFs**: Documents with complex <a href="https://pdftheguide.com/glossary/pdf-structure-element" target="_blank" rel="noopener">structure trees</a> contain many small structure element dictionaries. Compressing these into object streams can reduce file size by 15–30%. - **Forms with many fields**: AcroForm PDFs with hundreds of fields — each with a widget annotation dictionary — benefit substantially. Object streams reduce the individual overhead of each annotation dictionary. - **Simple documents (text + images)**: Fewer small objects mean smaller gains — typically 5–10% from object stream compression alone. - **Already-compressed files**: If the PDF was already optimised (images at optimal resolution, content streams compressed), the additional gain from object streams on the remaining objects is smaller.

Modern PDF generators (Acrobat, LibreOffice, pdf-lib configured with object stream output) produce object streams by default for PDF 1.5+ output.

Compatibility considerations

Object streams require a PDF 1.5+ reader. All current PDF viewers (Acrobat 6+, Chrome PDFium, Firefox PDF.js, macOS Preview 10.5+) support PDF 1.5 and object streams. Older viewers or custom PDF parsers written before 2005 may not.

For maximum compatibility with legacy systems (some older enterprise document management platforms, government archive validators written before 2010), it may be necessary to "linearise away" object streams — converting the file back to traditional xref table format. qpdf's <code>--object-streams=disable</code> flag does this explicitly.

<a href="https://pdftheguide.com/glossary/pdf-a" target="_blank" rel="noopener">PDF/A-1</a> (based on PDF 1.4) prohibits object streams. PDF/A-2 and PDF/A-3 (based on PDF 1.7) permit them, and modern PDF/A-2 generators routinely use object streams for size efficiency.

Frequently asked questions

Do object streams affect PDF compatibility with older readers?

Object streams require a PDF 1.5+ reader, published in 2003. All modern PDF viewers support them. The practical compatibility concern is with very old or niche systems: embedded PDF viewers in older copiers/scanners, first-generation digital signage systems, or legacy enterprise DMS platforms from the early 2000s. If you need to guarantee compatibility with such systems, use qpdf with --object-streams=disable to convert back to a traditional xref table format, at the cost of increased file size.

Can I use object streams with PDF/A?

Object streams are prohibited in PDF/A-1 (which is based on PDF 1.4). They are permitted in PDF/A-2 and PDF/A-3 (based on PDF 1.7), and modern PDF/A-2 and PDF/A-3 generators use them by default. If you are targeting PDF/A-1b conformance, your PDF generator must either not use object streams or strip them during the PDF/A conversion step.

How do object streams differ from content streams?

A content stream (/Type /Page content) carries the drawing instructions that render a page — text positioning operators, path drawing, image painting. An object stream (/Type /ObjStm) carries multiple PDF indirect objects packed together for compression purposes. Content streams are rendering data; object streams are structural storage optimisations. Content streams cannot be stored inside object streams (the PDF spec explicitly prohibits this).

How can I check whether a PDF uses object streams?

The simplest method is qpdf: run qpdf --check input.pdf — it reports whether the file uses object streams and cross-reference streams. In a hex editor, the absence of the traditional xref keyword near the end of the file and the presence of a stream object with /Type /XRef confirms cross-reference stream usage (which implies object stream support). Acrobat Pro's Document Properties panel does not report object stream usage directly, but the PDF Optimizer dialog (File > Save as Other > Optimized PDF) shows compression settings.