THotPDF.UseObjectStreams Property

 

THotPDF.UseObjectStreams

THotPDF

 

Top  Previous  Next

Pack eligible indirect objects into PDF 1.5 /Type /ObjStm container streams (ISO 32000-1 7.5.7) to shrink the on-disk PDF.

 

Delphi syntax:

property UseObjectStreams: Boolean;

 

C++ syntax:

__property bool UseObjectStreams;

 

Description

When UseObjectStreams is true (and UseXRefStream is true as well), EndDoc packs all eligible indirect objects - dictionaries, arrays, numbers, names, strings, booleans and nulls - into one or more /Type /ObjStm container streams per ISO 32000-1 7.5.7. The cross-reference stream then refers to the packed objects through type-2 entries (host ObjStm object number + entry index inside that stream), so the individual N G obj ... endobj framing bytes and the per-row textual xref entries disappear.

 

Works naturally alongside the UseXRefStream property for the most compact PDF 1.5+ writer pipeline. The ObjStm packer leaves stream objects, the encryption dictionary and the trailer-pointed Catalog and Info dictionaries uncompressed so that even minimal PDF parsers can still locate the document roots and decrypt the content.

 

Default value: false (opt-in).

Setting UseObjectStreams to true silently falls back to false when UseXRefStream is off (type-2 entries cannot be represented in the textual xref table, per the spec) or when Version is below PDF 1.5.

 

It is also forced off under PDF/A-1: ISO 19005-1 (PDF 1.4, clause 6.1.4) forbids compressed object streams together with the cross-reference streams they ride on, so EndDoc emits a classic xref table whenever PDFACompliance names a part-1 level, whilst PDF/A-2 and PDF/A-3 (PDF 1.7) leave it available

 

Code Example

HPDF := THotPDF.Create( nil );
try
  HPDF.FileName := 'c:\Output.pdf';
  HPDF.Version := pdf15;          // Object streams require PDF 1.5+
  HPDF.UseXRefStream := true;     // ObjStm references need a /Type /XRef stream
  HPDF.UseObjectStreams := true;  // Pack indirect objects into /Type /ObjStm
  HPDF.Compression := cmFlateDecode;
  HPDF.BeginDoc;
  HPDF.CurrentPage.TextOut( 100, 100, 0, 'Compact PDF 1.5 output' );
  HPDF.EndDoc;
finally
  HPDF.Free;
end;

 

Size savings

On documents dominated by small indirect dictionaries (multi-page documents, annotations, AcroForm widgets, structure-tree elements, Optional Content layers) the saving typically amounts to 20-40% of the post-FlateDecode file size. A 30-page graphics-only smoke test goes down from 14502 bytes to 8488 bytes (-41.5%).

 

See Also

UseXRefStream, Compression, Version, PDF Filter Support