Get, create or edit PDF interactive from actions in C# and VB.NET

GemBox.Pdf supports creating, removing and editing interactive form field actions.

Interactive form actions are represented by the following classes in GemBox.Pdf: PdfSubmitFormAction, PdfResetFormAction and PdfImportFormDataAction.

The following example demonstrates how to add submit form and reset form actions to button fields.

Screenshot of PDF 'submit form' action added with GemBox.Pdf
PDF 'submit form' action added with GemBox.Pdf
Upload your file (Drag file here)
using GemBox.Pdf;
using GemBox.Pdf.Forms;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        using (var document = PdfDocument.Load("%InputFileName%"))
        {
            // Get a button field.
            var submitButtonField = (PdfButtonField)document.Form.Fields["Submit"];

            // Create "submit form" field action.
            var submitFormAction = submitButtonField.Actions.AddSubmitForm("https://www.gemboxsoftware.com/");
            // Set XFDF (XML Forms Data Format) as form data export format.
            submitFormAction.ExportFormat = PdfFormDataFormat.XFDF;
            // Submit all form fields.
            submitFormAction.SelectedFields.All = true;

            // Get a button field.
            var resetButtonField = (PdfButtonField)document.Form.Fields["Reset"];

            // Create "reset form" field action.
            var resetFormAction = resetButtonField.Actions.AddResetForm();
            // Reset "Gender" and "Age" fields.
            resetFormAction.SelectedFields.Excluded = false;
            resetFormAction.SelectedFields.Add("Gender");
            resetFormAction.SelectedFields.Add("Age");

            document.Save("Form Actions.pdf");
        }
    }
}
Imports GemBox.Pdf
Imports GemBox.Pdf.Forms

Module Program

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Using document = PdfDocument.Load("%InputFileName%")

            ' Get a button field.
            Dim submitButtonField = CType(document.Form.Fields("Submit"), PdfButtonField)

            ' Create "submit form" field action.
            Dim submitFormAction = submitButtonField.Actions.AddSubmitForm("https://www.gemboxsoftware.com/")
            ' Set XFDF (XML Forms Data Format) as form data export format.
            submitFormAction.ExportFormat = PdfFormDataFormat.XFDF
            ' Submit all form fields.
            submitFormAction.SelectedFields.All = True

            ' Get a button field.
            Dim resetButtonField = CType(document.Form.Fields("Reset"), PdfButtonField)

            ' Create "reset form" field action.
            Dim resetFormAction = resetButtonField.Actions.AddResetForm()
            ' Reset "Gender" and "Age" fields.
            resetFormAction.SelectedFields.Excluded = False
            resetFormAction.SelectedFields.Add("Gender")
            resetFormAction.SelectedFields.Add("Age")

            document.Save("Form Actions.pdf")
        End Using
    End Sub
End Module

Check next example or download examples from GitHub.