Export PDF Form Data

9 Jul 20264 minutes to read

The WPF PDF Viewer supports exporting form field data in multiple formats, enabling easy storage and seamless integration with other systems. Supported formats:

Follow the steps below to export data from a PDF document in the UI.

  1. Click the form data tool button in the left pane, the form data toolbar will appear as a secondary toolbar in the PdfViewerControl.
  2. Select Export option in form data toolbar to export the PDF form data.
  3. In Export Form Data As dialog box, you can select the desired format to save the form data (FDF, XFDF, XML, and JSON).

NOTE

If the PDF document is loaded as a stream, the PdfViewerControl will request for the form name when exporting.

How to export programmatically

ExportFormData API is used to export the form fields data in code-behind. This API allows the values filled in form fields to be extracted and saved in the required format, making it useful for storing form data, sharing it with external systems, or reusing it at a later stage without manual intervention.

NOTE

The PDF document must contain form fields, and the document must be loaded into the PdfViewerControl before exporting.

Export as FDF

The following example exports form field data as FDF.

private void button1_Click(object sender, RoutedEventArgs e)
{
    //Export PDF form data
    pdfViewer.ExportFormData("Export.fdf", Syncfusion.Pdf.Parsing.DataFormat.Fdf, "SourceForm.pdf");
}
Private Sub button1_Click(sender As Object, e As RoutedEventArgs)
    'Export PDF form data
    pdfViewer.ExportFormData("Export.fdf", Syncfusion.Pdf.Parsing.DataFormat.Fdf, "SourceForm.pdf")
End Sub

Export as XFDF

The following example exports form field data as XFDF.

private void button1_Click(object sender, RoutedEventArgs e)
{
    //Export PDF form data
    pdfViewer.ExportFormData("Export.xfdf", Syncfusion.Pdf.Parsing.DataFormat.XFdf, "SourceForm.pdf");
}
Private Sub button1_Click(sender As Object, e As RoutedEventArgs)
    'Export PDF form data
    pdfViewer.ExportFormData("Export.xfdf", Syncfusion.Pdf.Parsing.DataFormat.XFdf, "SourceForm.pdf")
End Sub

Export as JSON

The following example exports form field data as JSON.

private void button1_Click(object sender, RoutedEventArgs e)
{
    //Export PDF form data
    pdfViewer.ExportFormData("Export.json", Syncfusion.Pdf.Parsing.DataFormat.Json, "SourceForm.pdf");
}
Private Sub button1_Click(sender As Object, e As RoutedEventArgs)
    'Export PDF form data
    pdfViewer.ExportFormData("Export.json", Syncfusion.Pdf.Parsing.DataFormat.Json, "SourceForm.pdf")
End Sub

Export as XML

The following example exports form field data as XML.

private void button1_Click(object sender, RoutedEventArgs e)
{
    //Export PDF form data
    pdfViewer.ExportFormData("Export.xml", Syncfusion.Pdf.Parsing.DataFormat.Xml, "SourceForm.pdf");
}
Private Sub button1_Click(sender As Object, e As RoutedEventArgs)
    'Export PDF form data
    pdfViewer.ExportFormData("Export.xml", Syncfusion.Pdf.Parsing.DataFormat.Xml, "SourceForm.pdf")
End Sub

ExportFormData parameters

  • fileName — Path of the output file to which the exported form data is written. Example: Export.fdf.
  • format — Format of the exported data from the DataFormat enum: Fdf, XFdf, Json, or Xml.
  • formName — Name of the PDF document containing the form fields. When the document is loaded as a stream, this value is prompted in the UI.

Common Use Cases

  • Save user-entered data to your server without altering the original PDF.
  • Export as JSON for REST API integration.
  • Export as FDF/XFDF for compatibility with other PDF tools.

See also