This example shows how to specify positioning in millimeters.
// 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 in absolute position
signOptions.setLocationMeasureType(MeasureType.Millimeters);signOptions.setLeft(40);signOptions.setTop(50);// set signature area in millimeters
signOptions.setSizeMeasureType(MeasureType.Millimeters);signOptions.setWidth(20);signOptions.setHeight(10);// set margin in millimeters
signOptions.setMarginMeasureType(MeasureType.Millimeters);Paddingpadding=newPadding();padding.setTop(5);padding.setLeft(5);padding.setRight(5);signOptions.setMargin(padding);// sign document
SignResultsignResult=signature.sign("signedSample.docx",options);// 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());}
Set signature positioning in percents
This example shows how to set different positioning properties in percentage.
// instantiating the signature object
finalSignaturesignature=newSignature("sample.pdf");try{// setup options with text of signature
BarcodeSignOptionssignOptions=newBarcodeSignOptions("12345678");// setup Barcode encoding type
signOptions.setEncodeType(BarcodeTypes.Code128);// set signature position in absolute position
signOptions.setLocationMeasureType(MeasureType.Percents);signOptions.setLeft(5);signOptions.setTop(5);// set signature area in percents
signOptions.setSizeMeasureType(MeasureType.Percents);signOptions.setWidth(10);signOptions.setHeight(5);// set margin in millimeters
signOptions.setMarginMeasureType(MeasureType.Percents);Paddingpadding=newPadding();padding.setTop(1);padding.setLeft(1);padding.setRight(1);signOptions.setMargin(padding);// sign document
SignResultsignResult=signature.sign("signed.docx",options);// 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.