Skip to main content
A newer version of this page is available. .

Export and Import Interactive Form Data

  • 3 minutes to read

This topic describes how to export and import AcroForm data (interactive form data) in various formats.

Export Interactive Form Data

Before exporting interactive form data, make sure the interactive form contains fields with filled values. To learn how to fill an interactive form with values, see the How to: Fill an Interactive Form with Values example.

To load a document with the required interactive form, call the PdfDocumentProcessor.LoadDocument method.

To export interactive form data from a document to FDF, XFDF, XML or TXT format, call one of the overloaded PdfDocumentProcessor.Export methods with the specified data format settings.

The following example shows how to export interactive form data from a PDF document to XML format.


using DevExpress.Pdf;

namespace ExportInteractiveForms {
    class Program {
        static void Main(string[] args) {

            using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {

                // Load a PDF document with AcroForm data. 
                processor.LoadDocument("..\\..\\InteractiveForm.pdf");

                // Export AcroForm data to XML format.
                processor.Export("..\\..\\InteractiveForm.xml", PdfFormDataFormat.Xml);
            }
        }
    }
}

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T491302.

You can also save the form data to the specified path and format calling one of the overloaded PdfFormData.Save methods.

To obtain interactive form data, call the PdfDocumentProcessor.GetFormData method.

See the code snippet below.


using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {    
      processor.LoadDocument(pathForPdf);
      PdfFormData data = processor.GetFormData();
      data.Save(pathForExportedData, PdfFormDataFormat.Fdf);
}    

Import Interactive Form Data

To load a document with an interactive form, call the PdfDocumentProcessor.LoadDocument method.

To import interactive form data either from FDF, XFDF, XML or TXT format to a PDF document, call one of the overloaded PdfDocumentProcessor.Import methods with data format settings or without them.

Note

The previous interactive form data is automatically removed from a document after the import operation is performed.

To save the document, call one of the overloaded PdfDocumentProcessor.SaveDocument methods.

The example below demonstrates how to import interactive form data from XML format.


using DevExpress.Pdf;

namespace ImportInteractiveForms {
    class Program {
        static void Main(string[] args) {

            using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {

                // Load a PDF document with AcroForm data.
                processor.LoadDocument("..\\..\\EmptyForm.pdf");

                // Import AcroForm data from an XML file.
                processor.Import("..\\..\\InteractiveForm.xml");

                // Save the imported document.
                processor.SaveDocument("..\\..\\InteractiveForm.pdf");
            }
        }
    }
}

Tip

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=T491383.