Locating signature on page with different measure units

GroupDocs.Signature supports locating signature on document page with different measure units. Enumeration MeasureType handles following types 

Here are the steps to locate and size signature area with different measure unit types:

Set signature positioning in millimeters

This example shows how to specify positioning in millimeters.

 // instantiating the signature object
final Signature signature = new Signature("sample.docx");
try
{
    // setup options with text of signature
    BarcodeSignOptions signOptions = new BarcodeSignOptions("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);
    Padding padding = new Padding();
    padding.setTop(5);
    padding.setLeft(5);
    padding.setRight(5);
    signOptions.setMargin(padding);
 
    // sign document    
    SignResult signResult = signature.sign("signedSample.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());
    } 
}catch (Exception e){
    throw new GroupDocsSignatureException(e.getMessage());
}

Set signature positioning in percents

This example shows how to set different positioning properties in percentage.

 // instantiating the signature object
final Signature signature = new Signature("sample.pdf");
try
{
   // setup options with text of signature
   BarcodeSignOptions signOptions = new BarcodeSignOptions("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);
   Padding padding = new Padding();
   padding.setTop(1);
   padding.setLeft(1);
   padding.setRight(1);
   signOptions.setMargin(padding);
 
   // sign document          
   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());
    }          
}catch (Exception e){
       throw new GroupDocsSignatureException(e.getMessage());
}

More resources

GitHub Examples 

You may easily run the code above and see the feature in action in our GitHub examples:

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.