SetDeterministicDocumentID
Document properties, Optimisation
Description
Enables or disables reproducible trailer file identifiers derived from an explicit seed or normalised serialised content
Syntax
Delphi
Function TPDFlib.SetDeterministicDocumentID(Enable: Integer): Integer;Parameters
| Enable | Pass 1 to derive the trailer file identifier from an explicit seed or normalised document content, or 0 to restore the default time-derived identifier. |
|---|
Return values
| 0 | Invalid parameter value. |
|---|---|
| 1 | Setting applied successfully. |
Remarks
When enabled, the next full unencrypted save derives the trailer /ID from the seed supplied with SetDocumentIDSeed. Without an explicit seed, the writer streams the serialised header and document body through SHA-256, normalises generated resource identifiers and XMP instance UUIDs, and uses the first 16 digest bytes for both entries of the initial /ID array. Cross-reference data, trailer offsets and any previous trailer /ID are excluded, so page, resource, attachment and metadata changes affect the identifier while layout offsets do not. The identifier is refreshed on full saves only. Incremental updates never rewrite the permanent identifier, and encrypted documents keep their existing identifier because the first
/ID entry participates in encryption key derivation. Automatic dates and other volatile user metadata remain content; set them explicitly when two independently generated documents must receive the same content-derived identifier
Example
PDF.SetDeterministicDocumentID(1);
PDF.SetDocumentIDSeed('invoice-2026-07-0001');
PDF.DrawText(100, 100, 'Reproducible output');
PDF.SaveToFile('invoice.pdf'); // same seed, same trailer IDSee also
GetDeterministicDocumentID, SetDocumentIDSeed, GetDocumentFileID