How do I add timestamps when signing a PDF document?

I was able to add a digital signature to a PDF with the Name, Reason, Location set in the document’s signature dictionary, but how do I add the signing time? Is a timestamp server required or can the timestamp be added locally by code?

Assuming you are referring to the time stamp that is attached to the signature dictionary (where the Name, Reason, Location are added), you will need to add the “M” field with the date value in PDF date format. For example:

// Add more information to the signature dictionary
sigDict.PutName(“SubFilter”, “adbe.pkcs7.detached”);
sigDict.PutString(“Name”, “PDFTron”);
sigDict.PutString(“Location”, “Vancouver, BC”);
sigDict.PutString(“Reason”, “Document verification.”);
sigDict.PutString(“M”, “D:20130417092950-07’00’”); // this time stamp indicates: 2013/04/17 09:29:50 (-7:00)

On the other hand, if you are referring to the timestamp that will be attached to the signature itself (i,e, signing time), this is usually done by either letting the cryptographic library add it (like in OpenSSL - see C++ sample), or use a TSA (Time Stamping Authority).