Sign documents with additional image adjustments

GroupDocs.Signature contains ImageAppearance class that implements extra image adjustment setting like

Base signature class SignOptions property setAppearance should be set with instance of ImageAppearance class to provide additional image adjustment

Here are the steps to setup extra image appearance with GroupDocs.Signature:

Sign document with image appearance

This example shows how to specify extra image appearances. See SignResult  

Signature signature = new Signature("sample.pdf");
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
options.setVerticalAlignment(VerticalAlignment.Bottom);
options.setHorizontalAlignment(HorizontalAlignment.Right);
Padding padding = new Padding();
padding.setBottom(20);
padding.setRight(20);
options.setMargin(padding);
 
    // setup image additional appearance as Brightness and Border
ImageAppearance imageAppearance = new ImageAppearance();
 
imageAppearance.setGrayscale(true);
imageAppearance.setContrast(0.2f);
imageAppearance.setGammaCorrection(0.3f);
imageAppearance.setBrightness(0.9f);
Border border = new Border();
 
border.setColor(Color.GREEN);
border.setDashStyle(DashStyle.DashLongDashDot);
border.setTransparency(0.5);
border.setVisible(true);
border.setWeight(2);
 
imageAppearance.setBorder(border);
options.setAppearance(imageAppearance);
 
// sign document to file
SignResult signResult = signature.sign("signed.pdf", 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());
}

Sign PDF document with Text signature Sticker appearance

This example shows how to add Text signature to Pdf document with sticker look. See SignResult  

Signature signature = new Signature("sample.docx");
{
    TextSignOptions options = new TextSignOptions("John Smith");

        // set signature position
    options.setLeft(100);
    options.setTop(100);
        // set signature rectangle
    options.setWidth(100);
    options.setHeight(30);
        // setup proper signature implementation
    options.setSignatureImplementation(TextSignatureImplementation.Sticker);
    PdfTextStickerAppearance appearance = new PdfTextStickerAppearance();
    // select sticker icon
    appearance.setIcon(PdfTextStickerIcon.Star);
    // setup if popup annotation will be opened by default
    appearance.setOpened(false);
    // text content of an annotation
    appearance.setContents("Sample");
    appearance.setSubject("Sample subject");
    appearance.setTitle("Sample Title");

    options.setAppearance(appearance);

        // set signature alignment
    options.setVerticalAlignment(VerticalAlignment.Bottom);
    options.setHorizontalAlignment(HorizontalAlignment.Right);
    Padding margin = new Padding();
    margin.setBottom(20);
    margin.setRight(20) ;
    options.setMargin(margin) ;
   
        // set text color and Font
    options.setForeColor(Color.RED);
    SignatureFont font =new SignatureFont();
    font.setSize(12); 
    font.setFamilyName("Comic Sans MS");
    options.setFont(font);

    // sign document to file
    signature.sign("signed.docx", options);
}

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.