A Timestamp can be added as part of your signature to show the date and time the document was signed. Time stamping can be done for both visible and non-visible signatures.
Specifying a Timestamp Server URL
If the signature will be time stamped from a Timestamp Server then a TimeStampServer object should be created. The TimestampServer object can be created by passing the URL of the Timestamp Server and if necessary the user name and password for connection. The TimeStampServer object should then be passed into the Documents Sign method along with the certificate and the name of the Signature Field.
This first example demonstrates using a TimestampServer object to specify the URL of the server to Timestamp the signature:
[Java]
Document document = new Document();
Page page = new Page();
//Create & add Signature Form Field
Signature signature = new Signature("SigField", 10, 10, 250, 100);
page.getElements().add(signature);
document.getPages().add(page);
Certificate certificate = new Certificate("[PhysicalPath]/JohnDoe.pfx", "password");
// Create TimestampServer
TimestampServer timestampServer = new TimestampServer("Url of the Timestamp Server");
document.sign("SigField", certificate,timestampServer);
document.draw("[PhysicalPath]/MyDocument.pdf");
Using a Timestamp Server URL from a Certificate
If the Certificate being used in the Signature Field already contains a Timestamp Server URL, this URL can also be used. In this case, there is no need to create a separate TimestampServer object. Rather the Documents Sign method overload that accepts a Signature Filed Name, a Certificate object and a Boolean value should be used. This Boolean value should be set to true implying that the signature will be time stamped using the details present in the Certificate object.
It is worth noting here that you checking Certificates TimeStampServer property will allow you to determine if there is a TimeStamp Server already specified or not. If the Certificate contains a URL then this property will return it otherwise it will return a Null.
This second example demonstrates how to use a Timestamp server URL that was already specified in the Certificate object:
[Java]
Document document = new Document();
Page page = new Page();
//Create & add Signature Form Field
Signature signature = new Signature("SigField", 10, 10, 250, 100);
page.getElements().add(signature);
document.getPages().add(page);
Certificate certificate = new Certificate("[PhysicalPath]/JohnDoe.pfx", "password");
// Field name should be one of the signature field name
document.sign("SigField", certificate,true);
document.draw("[PhysicalPath]/MyDocument.pdf");