ApplyPAdESSignatureTimeStamp

Digital signatures

Requires the Enterprise edition — in Delphi, C++Builder and Lazarus code create the library as TPDFlibEnterprise (unit PDFlibEnterprise); the Enterprise DLL and ActiveX builds provide it unchanged; other editions keep the method, which returns 0, an empty string or False and sets LastErrorCode to 900 (PDFLIB_ERROR_ENTERPRISE_REQUIRED)

Description

Completes a PAdES-B-T signature time-stamp in one call

Syntax

Delphi

Function TPDFlib.ApplyPAdESSignatureTimeStamp(STSProcessID, SignerIndex: Integer): Integer; Virtual;

ActiveX

Function PDFlib::ApplyPAdESSignatureTimeStamp(STSProcessID As Long, SignerIndex As Long) As Long

DLL

int DLApplyPAdESSignatureTimeStamp(int InstanceID, int STSProcessID, int SignerIndex);

Parameters

STSProcessIDA signature time-stamp process created by one of the NewPAdESSignatureTimeStampProcess functions
SignerIndexZero-based signer whose signature value is stamped

Return values

1The token was obtained and attached
0The exchange or the attachment failed; GetTimeStampError carries the reason

Remarks

This hashes the signature value of the process target field, requests a token from the authority set by SetTimeStampServer, and attaches it as the signature time-stamp unsigned attribute. Call one of the End functions afterwards to write the output. If a later signature or document time stamp covers the target signature value, the call fails and GetTimeStampError explains the overlap

The individual steps remain available for a caller that obtains tokens from elsewhere: GetPAdESSignatureValueHashHex then SetPAdESSignatureTimeStampToken

Example

PDF.SetTimeStampServer('https://tsa.example.com/tsa', '', '');
ProcessID:= PDF.NewPAdESSignatureTimeStampProcessFromFile('signed.pdf', '');
PDF.SetPAdESSignatureTimeStampField(ProcessID, 'Signature1');
if PDF.ApplyPAdESSignatureTimeStamp(ProcessID, 0)= 1 then
  PDF.EndPAdESSignatureTimeStampProcessToFile(ProcessID, 'signed-bt.pdf');
PDF.ReleasePAdESSignatureTimeStampProcess(ProcessID);

See also

FetchTimeStampToken, SetTimeStampServer, SetPAdESSignatureTimeStampToken