eSign document with Form Field signature

What is a Form Field?

A form field is the interactive element located on document page that allows user data input through various control types like free input text box, multi-line text box, check boxes, drop down lists etc. Different document types support specific list of form field types. These elements are used to collect information from user on template form. Each Form Field element has an unique name, settings and value field. Form Fields should have unique names within the form. Picture below demonstrates possible document page with form fields.

How to eSign document with Form Field signature

GroupDocs.Signature supports creation of new form fields or update existing ones within the documents. Class FormFieldSignOptions specifies different options for Form Field signature. The FormFieldSignOptions class contains one FormFieldSignature object to put to the document.
Here are the list of different Form Field signature classes that could be set to FormFieldSignOptions

Here are the steps to add Form Field signatures into document with GroupDocs.Signature:

NOTE: At the moment GroupDocs.Signature supports creation of Form Field signatures for PDF documents only.

This example shows how to sign PDF document with Form Field electronic signature on document page.

            // The path to the documents directory.
            string filePath = "sample.pdf";
            string fileName = Path.GetFileName(filePath);

            string outputFilePath = Path.Combine("C:\output", fileName);
            
			using (Signature signature = new Signature(filePath))
            {
                // Instantiate text form field signature
                FormFieldSignature textSignature = new TextFormFieldSignature("FieldText", "Value1");
                
				// Instantiate options based on text form field signature
                FormFieldSignOptions options = new FormFieldSignOptions(textSignature)
                {
                    HorizontalAlignment = HorizontalAlignment.Left,
                    VerticalAlignment = VerticalAlignment.Top,
                    Margin = new Padding(10, 20, 0, 0),
                    Height = 10,
                    Width = 100
                };
                // Sign document and save to the file
                signature.Sign(outputFilePath, options);
            }

How to eSign document with existing Form Field signatures

GroupDocs.Signature for .NET also provides mechanism to update existing form fields signatures within the documents.

Class TextSignOptions allows to setup different options for Form Field signature

Here are the steps to update existing form field signature within the document with GroupDocs.Signature:

This example shows how to e sign PDF document with existing Form Field electronic signature on document page and update its value.

// The path to the documents directory.
string filePath = "sample.pdf";
string fileName = Path.GetFileName(filePath);

string outputFilePath = Path.Combine("C:\output", fileName);
            
using (Signature signature = new Signature(filePath))
{
    TextSignOptions ffOptions1 = new TextSignOptions("Document is approved")
    {
        // set alternative signature implementation on document page
        SignatureImplementation = TextSignatureImplementation.FormField,
        FormTextFieldType = FormTextFieldType.PlainText
    };
    TextSignOptions ffOptions2 = new TextSignOptions("John Smith")
    {
        // set alternative signature implementation on document page
        SignatureImplementation = TextSignatureImplementation.FormField,
        FormTextFieldType = FormTextFieldType.RichText,
        FormTextFieldTitle = "UserSignatureFullName"
    };
    List<SignOptions> listOptions = new List<SignOptions>();
    listOptions.Add(ffOptions1);
    listOptions.Add(ffOptions2);
    // sign document to file
    SignResult signResult = signature.Sign(outputFilePath, listOptions);
}

More resources

Advanced Usage Topics

To learn more about document eSign features, please refer to the advanced usage section.

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.