Sign document with Form Field signature - advanced
Sign document with Form Field signature - advanced
Leave feedback
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.Siganture supports creation of Form Field signatures for Pdf documents only.
Analyze SignResult result to check newly created signatures if needed.
Sign Pdf document with Form Field signature
This example shows how to add Form Field signature to document. See SignResult
Signaturesignature=newSignature("sample.pdf");List<SignOptions>listOptions=newArrayList<SignOptions>();// instantiate text form field signature
FormFieldSignaturetextSignature=newTextFormFieldSignature("tbData1","Value-1");// instantiate options based on text form field signature
FormFieldSignOptionsoptionsTextFF=newFormFieldSignOptions(textSignature);optionsTextFF.setHorizontalAlignment(HorizontalAlignment.Left);optionsTextFF.setVerticalAlignment(VerticalAlignment.Top);optionsTextFF.setMargin(newPadding(10,20,0,0));optionsTextFF.setHeight(10);optionsTextFF.setWidth(100);// instantiate text form field signature
CheckboxFormFieldSignaturechbSignature=newCheckboxFormFieldSignature("chbData1",true);// instantiate options based on text form field signature
FormFieldSignOptionsoptionsTextCHB=newFormFieldSignOptions(chbSignature);optionsTextCHB.setHorizontalAlignment(HorizontalAlignment.Center);optionsTextCHB.setVerticalAlignment(VerticalAlignment.Top);optionsTextCHB.setMargin(newPadding(0,0,0,0));optionsTextCHB.setHeight(10);optionsTextCHB.setWidth(100);// instantiate text form field signature
DigitalFormFieldSignaturedigSignature=newDigitalFormFieldSignature("dgData1");// instantiate options based on text form field signature
FormFieldSignOptionsoptionsTextDIG=newFormFieldSignOptions(digSignature);optionsTextDIG.setHorizontalAlignment(HorizontalAlignment.Right);optionsTextDIG.setVerticalAlignment(VerticalAlignment.Top);optionsTextDIG.setMargin(newPadding(0,50,0,0));optionsTextDIG.setHeight(10);optionsTextDIG.setWidth(100);listOptions.add(optionsTextFF);listOptions.add(optionsTextCHB);listOptions.add(optionsTextDIG);// sign document to file
SignResultsignResult=signature.sign("signedSample.pdf",listOptions);// analyzing result
System.out.print("List of newly created signatures:");intnumber=1;for(BaseSignaturetemp: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:
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.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.