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 holds on to only a bounded tail probe instead of a complete copy of the source

 

New indirect objects and mutations performed through the loaded-document APIs are tracked automatically. Use MarkDirty when code changes an object by a path 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 whilst 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 whilst preserving the byte ranges covered by earlier digital signatures. The active trailer is used even when the source already contains several revisions

 

Adding a second signature

Once the document is loaded no page is current, so the signable field is added with AddLoadedSignedSignatureField, which takes the page index as a parameter. It sets aside the signature space that SignPDFWithPFX — or PreparePDFForSigning and InsertSignatureHex with an external signer — complete once the update has been saved. The fresh signature spans the whole file and the earlier signatures stay valid because their bytes are left untouched

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