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 shows how you can add submit form and reset form actions to button fields.

PDF 'submit form' action added with GemBox.Pdf
Screenshot of 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

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Pdf yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.