THotPDF.PreparePDFForSigning Method
Prepares an unsigned PDF for external signing by reserving the signature container area and producing byte ranges that the caller signs.
Declaration
class function PreparePDFForSigning(var PDFBytes: AnsiString; out Range1Start: Integer; out Range1Length: Integer; out Range2Start: Integer; out Range2Length: Integer; out ContentsHexStart: Integer; out ContentsHexLen: Integer): boolean;
Remarks
PDFBytes is the saved document that THPDFPage.AddSignedSignatureField prepared. The method replaces the /ByteRange placeholder with the real values in place and returns False when no placeholder is found
Range1Start,Range1Length,Range2StartandRange2Lengthare 0-based file offsets and lengths. Hash those two ranges, in that order, to get the digest the CMS signature covers- The bytes between the ranges are the complete
/Contentshexadecimal string, its<and>delimiters included, as ISO/IEC 32000-1 12.8.3.3 requires ContentsHexStartis the 1-based index of the first hex digit inPDFBytesandContentsHexLenthe number of hex digits reserved. Pass the hex-encoded signature toInsertSignatureHex, which pads a shorter value with zeros at the end