Skip to main content

DevExpress v24.1 Update — Your Feedback Matters

Our What's New in v24.1 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

Import and Export Interactive Form Data

  • 4 minutes to read

This document describes how to import and export AcroForm data (interactive forms that contain PDF fields used to gather information from the user) in FDF and XML formats.

#Import Interactive Form Data

#From the User Interface

If your document contains an interactive form, the Form Data ribbon tab or bar group becomes available. Click Import to invoke the Open dialog.

ImportFormData

Select a data file (e.g., in the FDF format) to import data and click Open.

ImportFormOpen

The imported interactive form data will be shown in the PDF Viewer.

ImportedForm

#In Code

Call the PdfViewerControl.ImportFormData in the PdfViewerControl.DocumentLoaded event handler to import AcroForm data.

The method invokes the Open dialog window, where you can specify a file name and file format (XML or FDF) from which a PDF document with interactive form is loaded.

View Example

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxpdf="http://schemas.devexpress.com/winfx/2008/xaml/pdf"
        x:Class="ImportFormData.MainWindow"
        Title="MainWindow" Height="450" Width="600">
    <Grid>

        <dxpdf:PdfViewerControl x:Name="Viewer"
                                DocumentLoaded="Viewer_DocumentLoaded"
                                DocumentClosing="Viewer_DocumentClosing"/>
    </Grid>
</Window>

#Export Interactive Form Data

#From the User Interface

If your document contains an interactive form, the Form Data ribbon tab or bar group becomes available. Click the Export button to export interactive form data from a PDF document to one of supported formats.

PDFExportForms

Specify a name and the format (FDF or XML) to export the form in the invoked dialog, and click Save.

ExportSaveAsDialog

#In Code

Call the PdfViewerControl.ExportFormData method in the PdfViewerControl.DocumentLoaded event handler to export interactive form data.

This method invokes the Save As dialog window, where you can specify the desired file format (XML or FDF) and a file name to export interactive form data.

View Example

<Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:dxpdf="http://schemas.devexpress.com/winfx/2008/xaml/pdf" 
        x:Class="ExportFormData.MainWindow"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        <dxpdf:PdfViewerControl x:Name="Viewer" DocumentLoaded="Viewer_DocumentLoaded" />
    </Grid>
</Window>

#Use Extension Methods to Import or Export Form Data

You can use DevExpress.Pdf.PdfViewerExtensions methods to import or export interactive form data with specified format settings. Add DevExpress.Docs reference to your application to access extension methods.

Important

You require a license to the DevExpress Office File API or DevExpress Universal Subscription to use this member in production code. Refer to the DevExpress Subscription page for pricing information.

The code samples below show how to use PdfViewerExtensions.Import and PdfViewerExtensions.Export methods to work with interactive form data.

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

// Import data from an XML format.
pdfViewer1.Import("..\\..\\FilledAcroForm.xml");

...

// Save the imported document.
pdfViewer1.SaveDocument("..\\..\\ImportedAcroForm.pdf");


// Export data to the XML format.
pdfViewer1.Export("..\\..\\AcroForm.xml", PdfFormDataFormat.Xml);