THotPDF.BeginIncrementalUpdate

THotPDF

 

Top  Methods  Next

Loads an existing PDF and switches the document into append-only incremental update mode.

 

Delphi syntax:

procedure BeginIncrementalUpdate(const SourceFile: TFileName); overload;

procedure BeginIncrementalUpdate(const SourceFile: TFileName; const Password: AnsiString); overload;

 

C++ syntax:

void __fastcall BeginIncrementalUpdate(System::Sysutils::TFileName SourceFile);

void __fastcall BeginIncrementalUpdate(System::Sysutils::TFileName SourceFile, const System::AnsiString Password);

 

Description

Call BeginIncrementalUpdate when an existing PDF must be extended without rewriting its original bytes. HotPDF parses the active trailer or xref-stream dictionary, captures its permanent and modification IDs, keeps the source file write-locked through a file-backed stream, and retains only a bounded tail probe instead of a complete source copy

 

New indirect objects and mutations performed through the loaded-document APIs are tracked automatically. Use MarkDirty when code changes an object through a path that is outside the official mutation hooks

 

For a Standard-encrypted source, pass either its user or owner password to the two-argument overload. For a public-key encrypted source, assign PubSecKeyMaterial and call the one-argument overload. HotPDF retains the authenticated file key or FEK only for the update lifetime, preserves the original string, stream, metadata, and Identity crypt-filter policies, and derives legacy per-object keys from both the object number and its retained generation

The encryption dictionary is inherited from the source revision and cannot be introduced, replaced, or reconfigured while incremental mode is active. Unsupported heterogeneous explicit crypt-filter rewrites fail before output rather than emitting ciphertext under a different policy

 

This workflow is useful for adding a later signature field, appending metadata, or extending an already signed document while preserving the byte ranges covered by earlier digital signatures. The active trailer is used even when the source already contains multiple revisions

 

Adding a second signature

No page is current after the document is loaded, so the signable field is added with AddLoadedSignedSignatureField, which takes the page index. It reserves the signature space that SignPDFWithPFX, or PreparePDFForSigning and InsertSignatureHex for an external signer, fill in after the update is saved. The new signature covers the whole file and the earlier signatures stay valid because their bytes are not touched

PDF := THotPDF.Create(nil);
try
  PDF.BeginIncrementalUpdate('Signed.pdf');
  PDF.AddLoadedSignedSignatureField(0, 300, 120, 500, 160, 'Approver', 8192);
  PDF.SaveIncrementalUpdate('Prepared.pdf');
finally
  PDF.Free;
end;
THotPDF.SignPDFWithPFX('Prepared.pdf', 'SignedTwice.pdf', 'Signer.pfx', 'password');

 

See also: MarkDirty, SaveIncrementalUpdate, AddLoadedSignedSignatureField, GetIncrementalUpdateSourceInfo, AcroForm Support, PDF Filter Support