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.
using(Signaturesignature=newSignature("sample.pdf")){TextSignOptionsoptions=newTextSignOptions("John Smith"){// set alternative signature implementation on document pageSignatureImplementation=TextSignatureImplementation.Stamp,// set alignmentVerticalAlignment=VerticalAlignment.Top,HorizontalAlignment=HorizontalAlignment.Right,// set margin with 20 pixels for all sidesMargin=newPadding(20)};// sign document to fileSignResultsignResult=signature.Sign("signed.pdf",options);// analyzing resultConsole.WriteLine("List of newly created signatures:");intnumber=1;foreach(BaseSignaturetempinsignResult.Succeeded){Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId},
Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");}}
Sign document with Text signature and Annotation implementation type
This example shows how to add Text signature with Annotation signature implementation to document.
using(Signaturesignature=newSignature("sample.pdf")){TextSignOptionsoptions=newTextSignOptions("John Smith"){// set alternative signature implementation on document pageSignatureImplementation=TextSignatureImplementation.Annotation,// for Pdf document type ther's ability to setup exteneded appearencesAppearance=newPdfTextAnnotationAppearance(){Border=newBorder(){Color=Color.Blue,DashStyle=DashStyle.Dash,Weight=2,},BorderEffect=PdfTextAnnotationBorderEffect.Cloudy,BorderEffectIntensity=2,HCornerRadius=10,// text content of an annotationContents="Sample",Subject="Sample subject",Title="Sample Title",},// set alignmentVerticalAlignment=VerticalAlignment.Top,HorizontalAlignment=HorizontalAlignment.Right,// set margin with 20 pixels for all sidesMargin=newPadding(20)};// sign document to fileSignResultsignResult=signature.Sign("signed.pdf",options);// analyzing resultConsole.WriteLine("List of newly created signatures:");intnumber=1;foreach(BaseSignaturetempinsignResult.Succeeded){Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId},
Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");}}
Sign document with Text signature and Image implementation type
This example shows how to add Text signature with Image signature implementation to document.
using(Signaturesignature=newSignature("sample.pdf")){TextSignOptionsoptions=newTextSignOptions("John Smith"){// set alternative signature implementation on document pageSignatureImplementation=TextSignatureImplementation.Image,// set alignmentVerticalAlignment=VerticalAlignment.Top,HorizontalAlignment=HorizontalAlignment.Right,// set margin with 20 pixels for all sidesMargin=newPadding(20)};// sign document to fileSignResultsignResult=signature.Sign("signed.pdf",options);// analyzing resultConsole.WriteLine("List of newly created signatures:");intnumber=1;foreach(BaseSignaturetempinsignResult.Succeeded){Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId},
Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");}}
Sign document with Text signature and Sticker implementation type
This example shows how to add Text signature with Sticker signature implementation to document.
using(Signaturesignature=newSignature("sample.pdf")){TextSignOptionsoptions=newTextSignOptions("John Smith"){// set alternative signature implementation on document pageSignatureImplementation=TextSignatureImplementation.Sticker,// set alignmentVerticalAlignment=VerticalAlignment.Top,HorizontalAlignment=HorizontalAlignment.Right,// set margin with 20 pixels for all sidesMargin=newPadding(20)};// sign document to fileSignResultsignResult=signature.Sign("signed.pdf",options);// analyzing resultConsole.WriteLine("List of newly created signatures:");intnumber=1;foreach(BaseSignaturetempinsignResult.Succeeded){Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId},
Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");}}
Sign document with Text signature and Form Field implementation type
This example shows how to add Text signature with FormField signature implementation to document.
using(Signaturesignature=newSignature("sample.docx")){TextSignOptionsffOptions1=newTextSignOptions("John Smith"){// set alternative signature implementation on document pageSignatureImplementation=TextSignatureImplementation.FormField,FormTextFieldType=FormTextFieldType.PlainText,FormTextFieldTitle="UserSignatureFullName"};TextSignOptionsffOptions2=newTextSignOptions("Document is approved"){// set alternative signature implementation on document pageSignatureImplementation=TextSignatureImplementation.FormField,FormTextFieldType=FormTextFieldType.RichText,FormTextFieldTitle="UserSignatureComment"};List<SignOptions>listOptions=newList<SignOptions>();listOptions.Add(ffOptions1);listOptions.Add(ffOptions2);// sign document to fileSignResultsignResult=signature.Sign("signed.docx",listOptions);// analyzing resultConsole.WriteLine("List of newly created signatures:");intnumber=1;foreach(BaseSignaturetempinsignResult.Succeeded){Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId},
Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}");}}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: