Locating signature with different alignments
Leave feedback
GroupDocs.Signature provides ability to align signature on page with horizontal and vertical alignment settings. Signature options that implement interface IAlignment contain following properties:
getMargin- property of class Padding to specify offset for signature alignment. Fields of class are Left, Top, Right, Bottom to specify offset in measure units from alignment area.
Here are the steps to align signature on page with GroupDocs.Signature:
Create a new instance of Signature class and pass source document path or stream as a constructor parameter.
Instantiate signature options (ImageSignOptions for example) with all required properties.
Set setHorizontalAlignment with one of enumeration value to align signature along page width
Set setVerticalAlignment with one of enumeration value to align signature along page height
Set setMargin property with required offsetfrom page border
Set setMarginMeasureType property with non default value if there is need to specify offset from page border in another measure units like millimeters and page percents (from 100% width and 100% height)
Call sign method of Signature class instance and pass the instance of signature options (ImageSignOptions for example) to it.
This example shows how to locate signature with different alignments.
// instantiating the signature object
finalSignaturesignature=newSignature("sample.pdf");// define qr-code size
intqrWidth=100;intqrHeight=100;// define list of options
List<SignOptions>listOptions=newArrayList<SignOptions>();// walk through all alignment values to locate signature at all page alignment areas
for(inthorizontalAlignment:HorizontalAlignment.getValues()){for(intverticalAlignment:VerticalAlignment.getValues()){if(verticalAlignment!=VerticalAlignment.None&&horizontalAlignment!=HorizontalAlignment.None){QrCodeSignOptionsoptions=newQrCodeSignOptions("Left-Top");options.setWidth(qrWidth);options.setHeight(qrHeight);// set signature alignment
options.setHorizontalAlignment(horizontalAlignment);options.setVerticalAlignment(verticalAlignment);options.setMargin(newPadding(5));listOptions.add(options);}}}// sign document to file
SignResultsignResult=signature.sign("signed.pdf",listOptions);// 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());}
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.