SetObjectStreamMode
Document properties, Optimisation
Description
Selects how full saves handle object streams: repack, keep the loaded file's original grouping, or write everything top-level.
Syntax
Delphi
Function TPDFlib.SetObjectStreamMode(Mode: Integer): Integer;Parameters
| Mode | 0 disables object streams (every object is written top-level); 1 generates fresh object streams from the live object graph (the default, PDF 1.5+); 2 preserves the loaded file's original ObjStm grouping. |
|---|
Return values
| 0 | Invalid mode value. |
|---|---|
| 1 | Mode selected. |
Remarks
Preserve mode makes converting existing PDF 1.5+ files cheaper: unchanged compressed members stay as type-2 entries against their source containers, which are written out verbatim, so nothing is unpacked or regrouped. Members edited since loading are promoted to top-level objects because their compressed slot still holds the original payload. Repacking and garbage collection are skipped on a preserve save, and documents below PDF 1.5 fall back to the normal materialising path. SetPackObjectStreams remains equivalent to modes 0 and 1.
Example
PDF.LoadFromFile('packed.pdf', '');
PDF.SetObjectStreamMode(2); // keep the original grouping
PDF.SetInformation(2, 'new title');
PDF.SaveToFile('retitled.pdf');See also
GetObjectStreamMode, SetPackObjectStreams, GetLastSaveUsedObjectStreams