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:
Margin- 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 HorizontalAlignment with one of enumeration value to align signature along page width
Set VerticalAlignment with one of enumeration value to align signature along page height
Set Margin property with required offsetfrom page border
Set MarginMeasureType 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.
using(Signaturesignature=newSignature("sample.pdf")){// define qr-code sizeintqrWidth=100;intqrHeight=100;// define list of optionsList<SignOptions>listOptions=newList<SignOptions>();// walk through all alignment values to locate signature at all page alignment areasforeach(HorizontalAlignmenthorizontalAlignmentinEnum.GetValues(typeof(HorizontalAlignment))){foreach(VerticalAlignmentverticalAlignmentinEnum.GetValues(typeof(VerticalAlignment))){if(verticalAlignment!=VerticalAlignment.None&&horizontalAlignment!=HorizontalAlignment.None){listOptions.Add(newQrCodeSignOptions("Left-Top"){// set signature rectangleWidth=qrWidth,Height=qrHeight,// set signature alignmentHorizontalAlignment=horizontalAlignment,VerticalAlignment=verticalAlignment,Margin=newPadding(5),});}}}// sign document to filesignature.Sign("signed.pdf",listOptions);}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: