PDFium Delphi Component Docs

CommitIncrementalSave method

Component: TPdf  ·  Unit: PDFium
Append the edits made since the last commit as a new PDF revision

Syntax

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

StreamDestination for the complete document, including the baseline and every revision appended so far; nil raises EPdfError
InfoTPdfIncrementalCommitInfo receives object and byte counts, prior and new xref offsets, revision count, encryption and validation state, and file durability results
ResultTrue when the complete validated output was written

 

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

FileNameDestination file, replaced atomically through a durable side file in the same directory
InfoThe same TPdfIncrementalCommitInfo report as the stream overload, with Durable and ReplacedAtomically set after those file stages succeed
ResultTrue when the validated side file replaced the destination

Description

Diffs the live document against the state captured at the last commit, or against the baseline for the first one, and appends the changed objects plus a fresh cross-reference section. Earlier bytes are never rewritten, so every previous revision stays byte-identical and recoverable

AppendedByteCount is the size of the new revision alone, whilst PreviousOutputByteCount and OutputByteCount delimit the immutable prefix and complete result. PreviousXrefOffset and OutputXrefOffset identify the revision chain, and ChangedObjectCount reports how many objects the diff found

Every candidate passes sparse revision-boundary checks, a strict independent reopen, page-count and security-handler checks, and PDF MAC validation when present. Encrypted and Validated report these properties

The file overload writes a side file beside the target, flushes it, closes and reopens it, and validates again before atomic replacement; Windows requests write-through replacement, whilst Unix checks directory-flush support first and flushes the parent directory after renaming

Failure before replacement preserves the target and restores the session baseline and revision count. If a Unix directory flush fails after a successful rename, the internal FPdfPlatform unit raises EPdfOutputCommitError: replacement has happened, Info.ReplacedAtomically=True and Info.Durable=False. The session keeps the committed baseline, preventing later edits from appending to obsolete output

Durable confirms that the platform's requested flush stages completed; it does not certify hardware or filesystem behaviour after power loss. Other save APIs sharing atomic replacement can likewise raise this exception after commitment, so distinguish it from failures that retain the previous output

Calling without an open session raises EPdfError, so BeginIncrementalSave must come first

See Also

BeginIncrementalSave, EndIncrementalSave, IncrementalSaveActive, SaveAs