Sign document with Digital signature - advanced

GroupDocs.Signature provides DigitalSignOptions class to specify different amount of settings for Digital signature

Here are the steps to add Digital signature into document with GroupDocs.Signature:

  • Create new instance of Signature class and pass source document path as a constructor parameter.
  • Instantiate the DigitalSignOptions object with required certificate and its password.
  • Call sign method of  Signature class instance and pass DigitalSignOptions to it.
  • Analyze SignResult result to check newly created signatures if needed.

This example shows how to sign PDF with Digital signature certificate and analyze SignResult

Signature signature = new Signature("sample.pdf"); 
DigitalSignOptions options = new DigitalSignOptions("certificate.pfx");
 
// certifiate password
options.setPassword("1234567890");
// digital certificate details
options.setReason("Sign");
options.setContact("JohnSmith");
options.setLocation("Office1");
 
// image as digital certificate appearance on document pages
options.setImageFilePath("sample.jpg");
//
options.setAllPages(true);
options.setWidth(80);
options.setHeight(60);
options.setVerticalAlignment(VerticalAlignment.Bottom);
options.setHorizontalAlignment(HorizontalAlignment.Right);
Padding padding = new Padding();
padding.setBottom(10);
padding.setRight(10);
options.setMargin(padding);
 
SignResult signResult = signature.sign("signed.pdf", options);
// analyzing result
System.out.print("List of newly created signatures:");
int number = 1;
for(BaseSignature temp : signResult.getSucceeded())
{
    System.out.print("Signature #"+ number++ +": Type: "+temp.getSignatureType()+" Id:"+temp.getSignatureId()+
            ",Location: "+temp.getLeft()+"x"+temp.getTop()+". Size: "+temp.getWidth()+"x"+temp.getHeight());
}

More resources

GitHub Examples 

You may easily run the code above and see the feature in action in our GitHub examples:

Free Online App 

Along with full-featured .NET library we provide simple, but powerful free Apps.
You are welcome to eSign PDF, Word, Excel, PowerPoint documents with free to use online GroupDocs Signature App.

Close
Loading

Analyzing your prompt, please hold on...

An error occurred while retrieving the results. Please refresh the page and try again.