Sign document with Form Field signature - advanced

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Signature MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-signature -- dnx GroupDocs.Signature.Mcp --yes
Folders, licensing and more →

GroupDocs.Signature provides FormFieldSignOptions class to specify different options for Form Field signature. The Form Field signature is special document predefined input field control with unique name inside the document content that expects some input from user.

At the moment GroupDocs.Signature supports creation of Form Field signatures for Pdf documents only.

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:

Sign Pdf document with  Form Field signature

This example shows how to add Form Field signature to document. See SignResult  

Signature signature = new Signature("sample.pdf");
 
List<SignOptions> listOptions = new ArrayList<SignOptions>();
 
// instantiate text form field signature
FormFieldSignature textSignature = new TextFormFieldSignature("tbData1", "Value-1");
// instantiate options based on text form field signature
FormFieldSignOptions optionsTextFF = new FormFieldSignOptions(textSignature);
optionsTextFF.setHorizontalAlignment(HorizontalAlignment.Left);
optionsTextFF.setVerticalAlignment(VerticalAlignment.Top);
optionsTextFF.setMargin(new Padding(10, 20, 0, 0));
optionsTextFF.setHeight(10);
optionsTextFF.setWidth(100);            
 
// instantiate text form field signature
CheckboxFormFieldSignature chbSignature = new CheckboxFormFieldSignature("chbData1", true);
// instantiate options based on text form field signature
FormFieldSignOptions optionsTextCHB = new FormFieldSignOptions(chbSignature) ;           
optionsTextCHB.setHorizontalAlignment(HorizontalAlignment.Center);
optionsTextCHB.setVerticalAlignment(VerticalAlignment.Top);
optionsTextCHB.setMargin(new Padding(0, 0, 0, 0));
optionsTextCHB.setHeight(10);
optionsTextCHB.setWidth(100);    
 
// instantiate text form field signature
DigitalFormFieldSignature digSignature = new DigitalFormFieldSignature("dgData1");
// instantiate options based on text form field signature
FormFieldSignOptions optionsTextDIG = new FormFieldSignOptions(digSignature);           
optionsTextDIG.setHorizontalAlignment(HorizontalAlignment.Right);
optionsTextDIG.setVerticalAlignment(VerticalAlignment.Top);
optionsTextDIG.setMargin(new Padding(0, 50, 0, 0));
optionsTextDIG.setHeight(10);
optionsTextDIG.setWidth(100);            
 
listOptions.add(optionsTextFF);
listOptions.add(optionsTextCHB);
listOptions.add(optionsTextDIG);
 
// sign document to file
SignResult signResult = signature.sign("signedSample.pdf", listOptions);
// analyzing result
System.out.print("List of newly created signatures:");
int number = 1;
for(BaseSignature temp : 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:

Free Online App 

Along with full-featured Java 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.