Sign documents with extra Digital Signature properties
GroupDocs.Signature contains DigitalSignatureAppearance class that implements extra settings for digital signature of Word Processing and Spreadsheets documents
Base signature options SignOptions property SignOptions.setAppearance should be set with instance of DigitalSignatureAppearance class to provide additional digital signature look
Here are the steps to setup extra image appearance with GroupDocs.Signature:
- Create new instance of Signature class and pass source document path as a constructor parameter.
- Compose object ofDigitalSignatureAppearance object with all required additional options.
- Set SignOptions.setAppearance property with DigitalSignatureAppearance object and set its properties
- Call sign method of Signature class instance and pass SignOptions to it.
- Analyze SignResult result to check newly created signatures if needed.
This example shows how to setup extra digital signature appearance. See SignResult
Signature signature = new Signature("sample.docx");
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(0);
options.setHeight(60);
options.setVerticalAlignment(VerticalAlignment.Bottom);
options.setHorizontalAlignment(HorizontalAlignment.Right);
Padding padding = new Padding();
padding.setBottom(10);
padding.setRight(10);
options.setMargin(padding);
// Setup signature line appearance.
// This appearance will add Signature Line on the first page.
// Could be useful for .xlsx files.
options.setAppearance(new DigitalSignatureAppearance("John Smith", "Title", "jonny@test.com"));
SignResult signResult = signature.sign("signed.docx", 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());
}
Sign Pdf document with Text signature Sticker appearance
This example shows how to add Text signature to Pdf document with sticker look. See SignResult
Signature signature = new Signature("sample.docx");
{
TextSignOptions options = new TextSignOptions("John Smith");
// set signature position
options.setLeft(100);
options.setTop(100);
// set signature rectangle
options.setWidth(100);
options.setHeight(30);
// setup proper signature implementation
options.setSignatureImplementation(TextSignatureImplementation.Sticker);
PdfTextStickerAppearance appearance = new PdfTextStickerAppearance();
// select sticker icon
appearance.setIcon(PdfTextStickerIcon.Star);
// setup if popup annotation will be opened by default
appearance.setOpened(false);
// text content of an annotation
appearance.setContents("Sample");
appearance.setSubject("Sample subject");
appearance.setTitle("Sample Title");
options.setAppearance(appearance);
// set signature alignment
options.setVerticalAlignment(VerticalAlignment.Bottom);
options.setHorizontalAlignment(HorizontalAlignment.Right);
Padding margin = new Padding();
margin.setBottom(20);
margin.setRight(20) ;
options.setMargin(margin) ;
// set text color and Font
options.setForeColor(Color.RED);
SignatureFont font =new SignatureFont();
font.setSize(12);
font.setFamilyName("Comic Sans MS");
options.setFont(font);
// sign document to file
signature.sign("signed.docx", options);
}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
- GroupDocs.Signature for .NET examples, plugins, and showcase
- GroupDocs.Signature for Java examples, plugins, and showcase
- Document Signature for .NET MVC UI Example
- Document Signature for .NET App WebForms UI Example
- Document Signature for Java App Dropwizard UI Example
- Document Signature for Java Spring UI Example
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.