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.
Following examples show different scenarios of using form fields on document page. These samples are supported for Pdf documents.
Sign Pdf document with various Form Field signatures
This example shows how to add various Form Field signature to document. See SignResult
using(Signaturesignature=newSignature("sample.pdf")){List<SignOptions>listOptions=newList<SignOptions>();// instantiate text form field signatureFormFieldSignaturetextSignature=newTextFormFieldSignature("tbData1","Value-1");// instantiate options based on text form field signatureFormFieldSignOptionsoptionsTextFF=newFormFieldSignOptions(textSignature){HorizontalAlignment=HorizontalAlignment.Left,VerticalAlignment=VerticalAlignment.Top,Margin=newPadding(10,20,0,0),Height=10,Width=100};// instantiate text form field signatureCheckboxFormFieldSignaturechbSignature=newCheckboxFormFieldSignature("chbData1",true);// instantiate options based on text form field signatureFormFieldSignOptionsoptionsTextCHB=newFormFieldSignOptions(chbSignature){HorizontalAlignment=HorizontalAlignment.Center,VerticalAlignment=VerticalAlignment.Top,Margin=newPadding(0,0,0,0),Height=10,Width=100,};// instantiate text form field signatureDigitalFormFieldSignaturedigSignature=newDigitalFormFieldSignature("dgData1");// instantiate options based on text form field signatureFormFieldSignOptionsoptionsTextDIG=newFormFieldSignOptions(digSignature){HorizontalAlignment=HorizontalAlignment.Right,VerticalAlignment=VerticalAlignment.Top,Margin=newPadding(0,50,0,0),Height=10,Width=100,};listOptions.Add(optionsTextFF);listOptions.Add(optionsTextCHB);listOptions.Add(optionsTextDIG);// sign document to filesignature.Sign("signedSample.pdf",listOptions);}
Sign PDF document with Combobox Form Field signature
This example shows how to add combo box Form Field signature to PDF document. See SignResult
// initialize Signature instanceusing(Signaturesignature=newSignature(filePath)){// instantiate combo box form field signatureList<string>items=newList<string>(){"Red","Green","Blue"};ComboboxFormFieldSignaturecombobox=newComboboxFormFieldSignature("combo1",items,"Blue");// instantiate options based on text form field signatureFormFieldSignOptionsoptions=newFormFieldSignOptions(combobox){HorizontalAlignment=HorizontalAlignment.Right,VerticalAlignment=VerticalAlignment.Top,Margin=newPadding(0,0,0,0),Height=100,Width=300,};// sign document to fileSignResultsignResult=signature.Sign("sampleSigned.pdf",options);}
Sign PDF document with Radio buttons Form Field signature
This example shows how to add radio buttons Form Field signature to PDF document. See SignResult
// initialize Signature instanceusing(Signaturesignature=newSignature(filePath)){// instantiate radio-button form field signatureList<string>radioOptions=newList<string>(){"One","Two","Three"};RadioButtonFormFieldSignatureradioSignature=newRadioButtonFormFieldSignature("radioData1",radioOptions,"Two");// instantiate options based on text form field signatureFormFieldSignOptionsoptions=newFormFieldSignOptions(radioSignature){HorizontalAlignment=HorizontalAlignment.Right,VerticalAlignment=VerticalAlignment.Top,Margin=newPadding(0,0,0,0),Height=100,Width=300,};// sign document to fileSignResultsignResult=signature.Sign("sampleSigned.pdf",options);}
More resources
GitHub Examples
You may easily run the code above and see the feature in action in our GitHub examples: