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 cut on-disk PDF size.

 

Delphi syntax:

property UseObjectStreams: Boolean;

 

C++ syntax:

__property bool UseObjectStreams;

 

Description

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

 

Pairs naturally with 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 even minimal PDF parsers can still locate document roots and decrypt content.

 

Default value: false (opt-in).

Setting UseObjectStreams to true silently downgrades to false when UseXRefStream is off (type-2 entries are not representable in the textual xref table per spec) or when Version is below PDF 1.5.

 

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 reduction

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

 

See Also

UseXRefStream, Compression, Version, PDF Filter Support