Back to Devexpress

How to: Export the AcroForm Data

wpf-114494-controls-and-libraries-pdf-viewer-examples-interactive-form-how-to-export-the-acroform-data.md

latest2.3 KB
Original Source

How to: Export the AcroForm Data

  • May 24, 2019

This example shows how to export AcroForm data (interactive form data) from a PDF document to XML or FDF format.

Call the PdfViewerControl.ExportFormData method in the PdfViewerControl.DocumentLoaded event handler. This method invokes the Save As dialog, where you can specify a desired file format (XML or FDF) and the file name.

View Example

xaml
<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>
csharp
using System.Windows;

namespace ExportFormData
{

    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            //Load a PDF file with an interactive form
            Viewer.OpenDocument("..\\..\\FormFillDemo.pdf");
        }

        private void Viewer_DocumentLoaded(object sender, RoutedEventArgs e)
        {
            //Load a PDF file with an interactive form
            Viewer.ExportFormData();
        }
    }
}
vb
Imports System.Windows

Namespace ExportFormData

    Partial Public Class MainWindow
        Inherits Window

        Public Sub New()
            InitializeComponent()
            ' Load a PDF file with an interactive form
            Viewer.OpenDocument("..\..\FormFillDemo.pdf")
        End Sub

        Private Sub Viewer_DocumentLoaded(ByVal sender As Object, ByVal e As RoutedEventArgs)
            ' Load a PDF file with an interactive form
            Viewer.ExportFormData()
        End Sub
    End Class
End Namespace