TextSignatureImplementation.Image - text will be transformed to image and put to document page. This implementation makes sense when there’s a need to adjust extended appearances effects that is possible with image adjustment only (like opacity, free rotation, fading, shadows etc).
TextSignatureImplementation.Watermark - text watermark along the document page under all document components. This implementation depends of document type.
Here are the steps to add Text signature into document with various text signature implementation types with GroupDocs.Signature:
Create new instance of Signature class and pass source document path as a constructor parameter.
Instantiate the TextSignOptions object with all required additional options.
Analyze SignResult result to check newly created signatures if needed.
Sign document with Text signature and Stamp implementation type
This example shows how to add Text signature with Stamp signature implementation to document.
Signaturesignature=newSignature("sample.pdf");{TextSignOptionsoptions=newTextSignOptions("John Smith");// set alternative signature implementation on document page
options.setSignatureImplementation(TextSignatureImplementation.Stamp);// set alignment
options.setVerticalAlignment(VerticalAlignment.Top);options.setHorizontalAlignment(HorizontalAlignment.Right);// set margin with 20 pixels for all sides
options.setMargin(newPadding(20));// 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());}}
Sign document with Text signature and Annotation implementation type
This example shows how to add Text signature with Annotation signature implementation to document.
Signaturesignature=newSignature("sample.pdf");{TextSignOptionsoptions=newTextSignOptions("John Smith");// set alternative signature implementation on document page
options.setSignatureImplementation(TextSignatureImplementation.Annotation);// for Pdf document type ther's ability to setup exteneded appearences
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 alignment
options.setVerticalAlignment(VerticalAlignment.Top);options.setHorizontalAlignment(HorizontalAlignment.Right);// set margin with 20 pixels for all sides
options.setMargin(newPadding(20));// sign document to file
SignResultsignResult=signature.sign("signed.pdf",options);// analyzing result
// 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 document with Text signature and Image implementation type
This example shows how to add Text signature with Image signature implementation to document.
Signaturesignature=newSignature("sample.pdf");{TextSignOptionsoptions=newTextSignOptions("John Smith");// set alternative signature implementation on document page
options.setSignatureImplementation(TextSignatureImplementation.Image);// set alignment
options.setVerticalAlignment(VerticalAlignment.Top);options.setHorizontalAlignment(HorizontalAlignment.Right);// set margin with 20 pixels for all sides
options.setMargin(newPadding(20));// 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());}}
Sign document with Text signature and Sticker implementation type
This example shows how to add Text signature with Sticker signature implementation to document.
Signaturesignature=newSignature("sample.pdf");{TextSignOptionsoptions=newTextSignOptions("John Smith");// set alternative signature implementation on document page
options.setSignatureImplementation(TextSignatureImplementation.Sticker);// set alignment
options.setVerticalAlignment(VerticalAlignment.Top);options.setHorizontalAlignment(HorizontalAlignment.Right);// set margin with 20 pixels for all sides
options.setMargin(newPadding(20));// 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());}}
Sign document with Text signature and Form Field implementation type
This example shows how to add Text signature with FormField signature implementation to document.
Signaturesignature=newSignature("sample.docx");{TextSignOptionsffOptions1=newTextSignOptions("John Smith");// set alternative signature implementation on document page
ffOptions1.setSignatureImplementation(TextSignatureImplementation.FormField);ffOptions1.setFormTextFieldType(FormTextFieldType.PlainText);ffOptions1.setFormTextFieldTitle("UserSignatureFullName");TextSignOptionsffOptions2=newTextSignOptions("Document is approved");// set alternative signature implementation on document page
ffOptions2.setSignatureImplementation(TextSignatureImplementation.FormField);ffOptions2.setFormTextFieldType(FormTextFieldType.RichText);ffOptions2.setFormTextFieldTitle("UserSignatureComment");List<SignOptions>listOptions=newArrayList<SignOptions>();listOptions.add(ffOptions1);listOptions.add(ffOptions2);// sign document to file
SignResultsignResult=signature.sign("signed.docx",listOptions);// 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.