API referenceDigital Signatures

pdfAddDocTimeStamp

Add a DocTimeStamp signature (RFC 3161, PAdES-style) by

C
BOOL32 __stdcall pdfAddDocTimeStampA(PPDF IPDF, const char* TSAUrl);
BOOL32 __stdcall pdfAddDocTimeStampW(PPDF IPDF, const wchar_t* TSAUrl);
Delphi
function pdfAddDocTimeStampA(const IPDF: PPDF; const TSAUrl: PAnsiChar): LongBool; stdcall;
function pdfAddDocTimeStampW(const IPDF: PPDF; const TSAUrl: PWideChar): LongBool; stdcall;

Purpose. Add a DocTimeStamp signature (RFC 3161, PAdES-style) by performing a real, live network round-trip to the TSA (timestamp authority) URL supplied.

Description. A complete, genuine RFC-3161 client, not a stub: (1) prepares an invisible DocTimeStamp signature covering the whole file via PrepareDeferredSign (the same deferred-sign machinery as pdfCloseAndSignFileExt above, internally); (2) computes the SHA-256 digest of the /ByteRange-covered bytes — the RFC-3161 "message imprint"; (3) builds a real timestamp request (BuildTimeStampReq, OID 2.16.840.1.101.3.4.2.1 = SHA-256) and performs a live HTTP(S) round-trip to TSAUrl (TSAFetch); (4) parses the TSA's response (ParseTimeStampResp), requiring status 0 (granted) or 1 (granted with modifications) and a non-empty token; (5) embeds the raw TimeStampToken bytes directly into /Contents and writes the final file (FinishDeferredSign). Any failure at any step (no document, bad URL, network failure, TSA rejection, empty token) aborts the whole operation and returns False — there is no partial-write or retry logic. pdfAddDocTimeStampW simply narrows TSAUrl to ANSI and forwards to the A form.

Parameters.

ParameterDescription
IPDFDocument handle.
TSAUrlThe RFC-3161 timestamp authority's HTTP(S) URL.

Return value. True only if the entire prepare→hash→request→parse→embed→write pipeline succeeds; False on any failure, including network/TSA errors.

C# (P/Invoke)

wrappers/dotnet/LumasPdf.cs
[return: MarshalAs(UnmanagedType.Bool)]
Area
Digital Signatures
Category

Content Creation

Exported names

pdfAddDocTimeStampA pdfAddDocTimeStampW

String variants

The …A form takes UTF-8, …W takes UTF-16; a bare name aliases the ANSI form.

See working code

Worked examples — complete programs in ten languages.