PDFium Delphi Component Docs

Incremental save session

Component: TPdf  ·  Unit: PDFium
Appends only changed or new indirect objects while preserving every previous output byte

Syntax

procedure BeginIncrementalSave(AllowSignedDocument: Boolean = False);

function CommitIncrementalSave(Stream: TStream; out Info: TPdfIncrementalCommitInfo): Boolean;

function CommitIncrementalSave(const FileName: string; out Info: TPdfIncrementalCommitInfo): Boolean;

procedure EndIncrementalSave;

property IncrementalSaveActive: Boolean;

AllowSignedDocumentExplicitly permits a session on a signed document; the default rejects it
StreamTStream that receives the complete accumulated PDF after this commit
FileNameOutput path replaced only after a sibling temporary file succeeds
InfoPer-commit statistics returned after the destination write succeeds

Commit Information

ChangedObjectCountNumber of changed or new indirect objects appended by this commit
AppendedByteCountBytes appended after the exact previous-output prefix
OutputByteCountTotal bytes in the complete output returned by this commit
RevisionCountNumber of non-empty revisions committed in the current session

Description

BeginIncrementalSave captures a stable PDFium semantic snapshot as both the comparison baseline and the first complete output

Each commit captures the current state, resolves active classic, hybrid, xref-stream, and object-stream objects, then compares object generation and exact body bytes

Only changed or new indirect objects are written after the previous output, followed by the smallest required xref and trailer revision

A classic-xref source continues with classic xref tables, while an xref-stream source continues with self-indexed xref streams

If nothing changed, the previous output is returned byte for byte, no revision is appended, and RevisionCount does not advance

The file overload writes a sibling temporary file, replaces the destination atomically, and restores session state if writing or replacement fails

Constraints

Example

var
  Info: TPdfIncrementalCommitInfo;
begin
  Pdf.BeginIncrementalSave;
  try
    Pdf.PageNumber := 1;
    Pdf.PageRotation := ro90;
    Pdf.CommitIncrementalSave('revision-1.pdf', Info);
    Pdf.PageRotation := ro180;
    Pdf.CommitIncrementalSave('revision-2.pdf', Info);
  finally
    Pdf.EndIncrementalSave;
  end;
end;

See Also

SaveAs, SaveAsObjectStream