HPDFWriteHeadlessSignatureReservation

Optional THPDFHeadlessSignatureMetadata values become Unicode Reason, Location, ContactInfo and Name entries; the same StringEncoder applies to both field-lock names and metadata before any bytes are written

function HPDFWriteHeadlessSignatureReservation(Target: TStream;
  ObjectNumber, Generation, ReservedCMSBytes, MaxObjectBytes: Integer;
  CAdES: Boolean = False; CertificationPermission: Integer = 0;
  CatalogObjectNumber: Integer = 0; CatalogGeneration: Integer = 0;
  FieldLock: PHPDFHeadlessFieldLock = nil;
  StringEncoder: THPDFHeadlessPolicyStringEncoder = nil;
  StringEncoderContext: Pointer = nil;
  Metadata: PHPDFHeadlessSignatureMetadata = nil;
  DocumentTimestamp: Boolean = False): THPDFHeadlessSignatureReservation;

Writes out a real indirect signature dictionary with fixed numeric ByteRange slots and a zero-filled hexadecimal Contents reservation

The caller owns the output stream and must supply a positive object number, a generation from 0 to 65535, a positive DER reservation and an object byte budget

The function checks the complete dictionary size before writing or allocating the reservation and fills its hexadecimal payload in bounded chunks

Set CAdES=true for ETSI.CAdES.detached; the default writes adbe.pkcs7.detached

Provide a valid Catalog reference and a certification permission from 1 to 3 to emit a DocMDP transform; an optional field lock emits its real FieldMDP transform in the same Reference array

Field lock names are validated and encoded as UTF-16BE PDF strings before writing the reservation; encrypted low-level callers provide a StringEncoder callback that is handed the plaintext bytes and returns the encrypted string bytes

The callback runs before any reservation bytes are written, and encoded expansion is included in the object budget; THPDFHeadlessDocument supplies the authenticated document encryption context automatically

Register the returned object offset with the shared xref writer, connect the object to a signature field and finish the PDF trailer before calling HPDFFinalizeHeadlessSignatureReservation

Low-level callers are responsible for staging and publication; THPDFHeadlessDocument.SignToFile provides source protection, encryption preservation, budgets and atomic file publication

DocumentTimestamp=true writes DocTimeStamp/ETSI.RFC3161 instead of an approval profile and prohibits certification or field-lock transform references; finalise it with HPDFFinalizeHeadlessDocumentTimestampReservation