PDFium Delphi Component Docs

Page-object edit transactions

Component: TPdf  ·  Unit: PDFium
Groups native page-object mutations into one atomic page-scoped operation

Syntax

procedure BeginPageObjectEditTransaction(AllowSignedDocument: Boolean = False; PreserveSourceEvents: Boolean = False);
function CommitPageObjectEditTransaction: Boolean;
procedure RollbackPageObjectEditTransaction;
property PageObjectEditTransactionStatus: TPdfPageObjectEditTransactionStatus;

Description

BeginPageObjectEditTransaction captures a bounded reproducible snapshot of the active document and binds the transaction to the current page

Page-object insert, remove, transform, property, content-mark, annotation-object and annotation-appearance mutations remain native PDFium operations whilst content generation is deferred

CommitPageObjectEditTransaction calls FPDFPage_GenerateContent once when at least one mutation succeeded and returns True, or returns False without generation for a no-op transaction

RollbackPageObjectEditTransaction restores the validated baseline snapshot without serialising deferred mutations

Status

TPdfPageObjectEditTransactionStatus reports Active, Dirty, the one-based PageNumber, successful MutationCount and ContentGenerationCount

The PageObjectEditTransactionStatus property returns that record live, so callers can poll the transaction state between mutations and read the final counters after commit or rollback

The final mutation and generation counters remain available after commit for diagnostics

Failure behaviour

Example

Pdf.BeginPageObjectEditTransaction;
try
  Pdf.TransformPageObject(0, Matrix);
  Pdf.SetPageObjectMarkParam(0, 0, Param);
  Pdf.CommitPageObjectEditTransaction;
except
  if Pdf.PageObjectEditTransactionStatus.Active then
    Pdf.RollbackPageObjectEditTransaction;
  raise;
end;

Source-event preserving batches

Pass PreserveSourceEvents=True as the second argument of BeginPageObjectEditTransaction to request preserving generation; internal v3.405.0 supports text, paths, named images, Form invocation geometry and private dirty untagged Form subtrees

A dirty preserving commit generates once; unsupported source/edit combinations or a missing extension restore the snapshot and raise EPdfError, with no ordinary-generation fallback

A transaction with no mutations returns False without generating or certifying source compatibility

Commit failure already closes and restores the transaction; call explicit rollback in an exception handler only whilst PageObjectEditTransactionStatus.Active remains True

See Also

BeginEditTransaction, UpdatePageObject, AddPageObjectMark, RefreshAppearance