eSign document with Form Field signature

What is a Form Field?

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.

FormField

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:

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

Note
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.
const filePath = Constants.SAMPLE_PDF; // Assuming Constants.SAMPLE_PDF is defined elsewhere
const fileName = path.basename(filePath);

const outputFilePath = path.join(Constants.OutputPath, 'SignPdfWithFormField', fileName);
const signature = new signatureLib.Signature(filePath);

// Instantiate text form field signature
const textSignature = new signatureLib.TextFormFieldSignature('FieldText', 'Value1');
// Instantiate options based on text form field signature
const options = new signatureLib.FormFieldSignOptions(textSignature);
options.setMargin(new signatureLib.Padding(10, 20, 0, 0));
options.setHeight(10);
options.setWidth(100);

// Sign document to file
signature.sign(outputFilePath, options);
console.log(`\nSource document signed successfully.\nFile saved at ${outputFilePath}`);

How to eSign document with existing Form Field signatures

GroupDocs.Signature for Node.Js via Java 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:

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.
  const filePath = Constants.SAMPLE_PDF; // Assuming Constants.SAMPLE_PDF is defined elsewhere
  const fileName = path.basename(filePath);

  const outputFilePath = path.join(Constants.OutputPath, 'SignPdfWithFormField', fileName);
  const signature = new signatureLib.Signature(filePath);

  // Instantiate text form field signature
  const textSignature = new signatureLib.TextFormFieldSignature('FieldText', 'Value1');
  // Instantiate options based on text form field signature
  const options = new signatureLib.FormFieldSignOptions(textSignature);
  options.setMargin(new signatureLib.Padding(10, 20, 0, 0));
  options.setHeight(10);
  options.setWidth(100);

  // Sign document to file
  signature.sign(outputFilePath, options);
  console.log(`\nSource document signed successfully.\nFile saved at ${outputFilePath}`);

Summary

This guide explains how to use GroupDocs.SignatureΒ to add form field signatures to documents. It covers loading a document, configuring form field properties such as name, type, and value, and saving the signed document. Advanced options, like customizing field appearance and placement, are also included. For more details, refer to related guides on document signing techniques.

More resources

GitHub Examples

You may easily run the code above and see the feature in action in ourΒ GitHub examples:

Free Online Apps

Along with the full-featured .NET library, we provide simple but powerful free online apps.

To sign PDF documents for free, you can use the Digital Signature - PDF online application.

To sign Word, Excel, PowerPoint, and other documents you can use the other online apps from the GroupDocs.Signature App Product Family.