A form field is an interactive element located on a document page that allows user data input through various control types like free input text boxes, multi-line text boxes, checkboxes, drop-down lists, etc. Different document types support a specific list of form field types. These elements are used to collect information from users on template form. Each Form Field element has a unique name, settings and value field. Form Fields should have unique names within the form. The picture below demonstrates a possible document page with form fields.
How to eSign document with Form Field signature
With GroupDocs.Signature you can create new form fields or update the existing ones within the documents. The FormFieldSignOptions class specifies different options for Form Field signature. The FormFieldSignOptions class contains one FormFieldSignature object that specifies the properties of the desired signature.
Below are listed different Form Field signature classes that could be set to FormFieldSignOptions:
Currently GroupDocs.Signature supports the creation of Form Field signatures for PDF documents only.
This example shows how to sign a PDF document with a Form Field electronic signature.
// The path to the documents directory.stringfilePath="sample.pdf";stringfileName=Path.GetFileName(filePath);stringoutputFilePath=Path.Combine("C:\output",fileName);using(Signaturesignature=newSignature(filePath)){// Instantiate text form field signatureFormFieldSignaturetextSignature=newTextFormFieldSignature("FieldText","Value1");// Instantiate options based on text form field signatureFormFieldSignOptionsoptions=newFormFieldSignOptions(textSignature){HorizontalAlignment=HorizontalAlignment.Left,VerticalAlignment=VerticalAlignment.Top,Margin=newPadding(10,20,0,0),Height=10,Width=100};// Sign document and save to the filesignature.Sign(outputFilePath,options);}
How to eSign document with existing Form Field signatures
GroupDocs.Signature for .NET also provides a mechanism to update the existing form field signatures within the documents.
To update an existing form field signature within the document with GroupDocs.Signature:
Create a new instance of the Signature class and pass the source document path as a constructor parameter.
Instantiate the TextSignOptions object with all required additional options.
Analyze the SignResult object to check the newly created signatures if needed.
This example shows how to sign a PDF document with the existing Form Field electronic signature and update its value.
// The path to the documents directory.stringfilePath="sample.pdf";stringfileName=Path.GetFileName(filePath);stringoutputFilePath=Path.Combine("C:\output",fileName);using(Signaturesignature=newSignature(filePath)){TextSignOptionsffOptions1=newTextSignOptions("Document is approved"){// set alternative signature implementation on document pageSignatureImplementation=TextSignatureImplementation.FormField,FormTextFieldType=FormTextFieldType.PlainText};TextSignOptionsffOptions2=newTextSignOptions("John Smith"){// set alternative signature implementation on document pageSignatureImplementation=TextSignatureImplementation.FormField,FormTextFieldType=FormTextFieldType.RichText,FormTextFieldTitle="UserSignatureFullName"};List<SignOptions>listOptions=newList<SignOptions>();listOptions.Add(ffOptions1);listOptions.Add(ffOptions2);// sign document to fileSignResultsignResult=signature.Sign(outputFilePath,listOptions);}
Advanced Usage Topics
To learn more about document eSign features, please refer to theΒ advanced usage section.
More resources
GitHub Examples
You may easily run the code above and see the feature in action in ourΒ GitHub examples: