Analyze SignResult result to check newly created signatures if needed.
This example shows how to add Barcode signature to document. See SignResult
// instantiating the signature object
finalSignaturesignature=newSignature("sample.docx");try{// setup options with text of signature
BarcodeSignOptionssignOptions=newBarcodeSignOptions("12345678");// setup Barcode encoding type
signOptions.setEncodeType(BarcodeTypes.Code128);// set signature position
signOptions.setLeft(100);signOptions.setTop(100);// when VerticalAlignment is set the Top coordinate will be ignored.
// Use Margin properties Top, Bottom to provide vertical offset
signOptions.setVerticalAlignment(VerticalAlignment.Top);// when HorizontalAlignment is set the Left coordinate will be ignored.
// Use Margin properties Left, Right to provide horizontal offset
signOptions.setHorizontalAlignment(HorizontalAlignment.Right);Paddingpadding=newPadding();padding.setLeft(20);padding.setTop(20);signOptions.setMargin(padding);// adjust signature appearance
// setup signature border
Borderborder=newBorder();border.setColor(Color.GREEN);border.setDashStyle(DashStyle.DashLongDashDot);border.setWeight(2);border.setTransparency(0.5);border.setVisible(true);signOptions.setBorder(border);// set text color and Font
signOptions.setForeColor(Color.RED);SignatureFontfont=newSignatureFont();font.setSize(12);font.setFamilyName("Comic Sans MS");signOptions.setFont(font);// specify position of text with barcode line
signOptions.setCodeTextAlignment(CodeTextAlignment.Above);// setup background
Backgroundbackground=newBackground();background.setColor(Color.GREEN);background.setTransparency(0.5);background.setBrush(newLinearGradientBrush(Color.GREEN,Color.DARK_GRAY,0));signOptions.setBackground(background);// sign document
ignResultsignResult=signature.sign("SampleSigned.docx",signOptions);// analyzing result
System.out.print("List of newly created signatures:");intnumber=1;for(BaseSignaturetemp: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());}}catch(Exceptione){thrownewGroupDocsSignatureException(e.getMessage());}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples:
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.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.