Sign document with Image signature - advanced

GroupDocs.Signature provides ImageSignOptions class to specify different options for Image signature as follow

Here are the steps to add Image signature into document with GroupDocs.Signature:

  • Create new instance of Signature class and pass source document path as a constructor parameter.
  • Instantiate the ImageSignOptions object according to your requirements and specify image signature options.
  • Call sign method of Signature class instance and pass ImageSignOptions to it.
  • Analyze SignResult result to check newly created signatures if needed.

This example shows how to specify different Image signature options. See SignResult 

Signature signature = new Signature(sample.xlsx);
 
ImageSignOptions options = new ImageSignOptions("sample.jpg");
 
// set signature position
options.setLeft(100);
options.setTop(100);
 
// set signature rectangle
options.setWidth(100);
options.setHeight(30);
 
// set signature alignment
// when VerticalAlignment is set the Top coordinate will be ignored.
// Use Margin properties Top, Bottom to provide vertical offset
options.setVerticalAlignment(VerticalAlignment.Top);
 
// when HorizontalAlignment is set the Left coordinate will be ignored.
// Use Margin properties Left, Right to provide horizontal offset
options.setHorizontalAlignment(HorizontalAlignment.Right);
 
Padding padding = new Padding();
padding.setRight(20);
padding.setTop(20);
options.setMargin(padding);
 
// set rotation
options.setRotationAngle(45);
 
//setup signature border
Border border = new Border();
border.setColor(Color.GREEN);
border.setDashStyle(DashStyle.DashLongDashDot);
border.setWeight(5);
border.setVisible(true);

options.setBorder(border);
 
// sign document to file
SignResult signResult = signature.sign("sgnedSample.xlsx", 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());
}

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.