Sign document with Form Field signature - advanced

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.

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:

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 (Signature signature = new Signature("sample.pdf"))
{
    List<SignOptions> listOptions = new List<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)
    {
        HorizontalAlignment = HorizontalAlignment.Left,
        VerticalAlignment = VerticalAlignment.Top,
        Margin = new Padding(10, 20, 0, 0),
        Height = 10,
        Width = 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)
    {
        HorizontalAlignment = HorizontalAlignment.Center,
        VerticalAlignment = VerticalAlignment.Top,
        Margin = new Padding(0, 0, 0, 0),
        Height = 10,
        Width = 100,
    };
    // instantiate text form field signature
    DigitalFormFieldSignature digSignature = new DigitalFormFieldSignature("dgData1");
    // instantiate options based on text form field signature
    FormFieldSignOptions optionsTextDIG = new FormFieldSignOptions(digSignature)
    {
        HorizontalAlignment = HorizontalAlignment.Right,
        VerticalAlignment = VerticalAlignment.Top,
        Margin = new Padding(0, 50, 0, 0),
        Height = 10,
        Width = 100,
    };
    listOptions.Add(optionsTextFF);
    listOptions.Add(optionsTextCHB);
    listOptions.Add(optionsTextDIG);
    // sign document to file
    signature.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 instance
using (Signature signature = new Signature(filePath))
{
    // instantiate combo box form field signature
    List<string> items = new List<string>() { "Red", "Green", "Blue" };
    ComboboxFormFieldSignature combobox = new ComboboxFormFieldSignature("combo1", items, "Blue");
    // instantiate options based on text form field signature
    FormFieldSignOptions options = new FormFieldSignOptions(combobox)
    {
        HorizontalAlignment = HorizontalAlignment.Right,
        VerticalAlignment = VerticalAlignment.Top,
        Margin = new Padding(0, 0, 0, 0),
        Height = 100,
        Width = 300,
    };
    // sign document to file
    SignResult signResult = 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 instance
using (Signature signature = new Signature(filePath))
{
    // instantiate radio-button form field signature
    List<string> radioOptions = new List<string>() { "One", "Two", "Three" };
    RadioButtonFormFieldSignature radioSignature = new RadioButtonFormFieldSignature("radioData1", radioOptions, "Two");
    // instantiate options based on text form field signature
    FormFieldSignOptions options = new FormFieldSignOptions(radioSignature)
    {
        HorizontalAlignment = HorizontalAlignment.Right,
        VerticalAlignment = VerticalAlignment.Top,
        Margin = new Padding(0, 0, 0, 0),
        Height = 100,
        Width = 300,
    };
    // sign document to file
    SignResult signResult = 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:

Free Online Apps

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

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