Analyze SignResult result to check newly created signatures if needed.
Sign Pdf document with Text signature Annotation appearance
This example shows how to add Text signature to Pdf document with annotation look. See SignResult
Signaturesignature=newSignature("sample.pdf");TextSignOptionsoptions=newTextSignOptions("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.Annotation);PdfTextAnnotationAppearanceappearance=newPdfTextAnnotationAppearance();Borderborder=newBorder();border.setColor(Color.BLUE);border.setDashStyle(DashStyle.Dash);border.setWeight(2);appearance.setBorder(border);appearance.setBorderEffect(PdfTextAnnotationBorderEffect.Cloudy);appearance.setBorderEffectIntensity(2);appearance.setHCornerRadius(10);// 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);Paddingpadding=newPadding();padding.setBottom(20);padding.setRight(20);options.setMargin(padding);// set text color and Font
options.setForeColor(Color.RED);SignatureFontsignatureFont=newSignatureFont();signatureFont.setSize(12);signatureFont.setFamilyName("Comic Sans MS");options.setFont(signatureFont);// sign document to file
SignResultsignResult=signature.sign("signedAnnotation.pdf",options);// 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());}
Sign Pdf document with Text signature Sticker appearance
This example shows how to add Text signature to Pdf document with sticker look. See SignResult
Signaturesignature=newSignature("sample.pdf");TextSignOptionsoptions=newTextSignOptions("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);PdfTextStickerAppearanceappearance=newPdfTextStickerAppearance();// 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);Paddingpadding=newPadding();padding.setBottom(20);padding.setRight(20);options.setMargin(padding);// set text color and Font
options.setForeColor(Color.RED);SignatureFontsignatureFont=newSignatureFont();signatureFont.setSize(12);signatureFont.setFamilyName("Comic Sans MS");options.setFont(signatureFont);// sign document to file
SignResultsignResult=signature.sign("signed.pdf",options);// 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.