Back to Devexpress

PdfViewerControl.ImportFormData() Method

wpf-devexpress-dot-xpf-dot-pdfviewer-dot-pdfviewercontrol-0de2c831.md

latest4.6 KB
Original Source

PdfViewerControl.ImportFormData() Method

Imports interactive data either from XML or FDF data format into a PDF form.

Namespace : DevExpress.Xpf.PdfViewer

Assembly : DevExpress.Xpf.PdfViewer.v25.2.dll

NuGet Package : DevExpress.Wpf.PdfViewer

Declaration

csharp
public void ImportFormData()
vb
Public Sub ImportFormData

Remarks

The ImportFormData 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.

You can call the ImportFormData method in the PdfViewerControl.DocumentLoaded event handler after a PDF document is loaded.

View Example: WPF PDF Viewer - Import/Export the AcroForm Data

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="ImportFormData.MainWindow"
        Title="MainWindow" Height="450" Width="600">
    <Grid>

        <dxpdf:PdfViewerControl x:Name="Viewer"
                                DocumentLoaded="Viewer_DocumentLoaded"
                                DocumentClosing="Viewer_DocumentClosing"/>
    </Grid>
</Window>
csharp
using DevExpress.Xpf.PdfViewer;
using System.Windows;

namespace ImportFormData {

    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)
        {
            //Import data for an interactive form and save the result
            Viewer.ImportFormData();
            Viewer.SaveDocument("..\\..\\ImportedDocument.pdf");
        }

        //Disable the Save File dialog
        private void Viewer_DocumentClosing(DependencyObject d, DocumentClosingEventArgs e)
        {
            e.SaveDialogResult = MessageBoxResult.Cancel;
            e.Handled = true;
        }
    }
}
vb
Imports DevExpress.Xpf.PdfViewer
Imports System.Windows

Namespace ImportFormData

    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)

            ' Import data for an interactive form and save the result
            Viewer.ImportFormData()
            Viewer.SaveDocument("..\..\ImportedDocument.pdf")
        End Sub

        ' Disable the Save File dialog
        Private Sub Viewer_DocumentClosing(ByVal d As DependencyObject, ByVal e As DocumentClosingEventArgs)
            e.SaveDialogResult = MessageBoxResult.Cancel
            e.Handled = True
        End Sub
    End Class
End Namespace

You can use PdfViewerExtensions.Import method to import 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.

Refer to the How to: Import the AcroForm Data topic for more information.

See Also

PdfViewerControl Class

PdfViewerControl Members

DevExpress.Xpf.PdfViewer Namespace