PDFium Delphi Component Docs

SaveAsObjectStream method

Component: TPdf  ·  Unit: PDFium
Writes a compact PDF 1.5+ copy using bounded object streams and a complete xref stream

Syntax

function SaveAsObjectStream(Stream: TStream; Option: TSaveOption = saNone; PdfVersion: TPdfVersion = pvUnknown; MaxObjectsPerStream: Integer = 100; MaxDecodedBytesPerStream: Integer = 65536): Boolean;

function SaveAsObjectStream(const FileName: string; Option: TSaveOption = saNone; PdfVersion: TPdfVersion = pvUnknown; MaxObjectsPerStream: Integer = 100; MaxDecodedBytesPerStream: Integer = 65536): Boolean;

StreamTStream that receives the complete object-stream PDF
FileNameOutput path replaced only after a sibling temporary file succeeds
OptionNormal save option or saRemoveSecurity; saIncremental is rejected
PdfVersionOutput version from PDF 1.5 upward, or pvUnknown to preserve or upgrade the current version
MaxObjectsPerStreamMaximum object members per ObjStm group; the default is 100
MaxDecodedBytesPerStreamMaximum decoded member payload per group; the default is 65536 bytes

Return Value

Returns True when the object-stream output was completed successfully

Description

The method first uses the normal PDFium save path as the semantic source, then resolves the active classic, hybrid, or xref-stream revision

Existing object-stream members are materialized before references are renumbered into page-local order

Eligible non-stream objects are grouped by both member count and decoded payload size, then Flate-compressed only when compression reduces the group

The catalog, stream objects, signature dictionaries, indirect stream lengths, and oversized values remain directly addressable

A pure xref stream uses adaptive field widths and type-2 entries for every compressed member

Constraints

Example

// Balance compact output with bounded random-access decompression
Pdf.SaveAsObjectStream('report-compact.pdf', saNoIncremental, pv17, 100, 65536);

See Also

SaveAs, SaveAsLinearized