How to export XFA data from existing XFA PDF document in WinForms PDF?
The Syncfusion Essential® PDF is a feature-rich and high-performance .NET PDF library that is used to create, read, and edit PDF documents programmatically without Adobe dependencies. This library also offers functionality to merge, split, stamp, forms, compress, and secure PDF files. Using this library, you can export the XFA data from an existing XFA PDF document.
Steps to export the XFA data from an existing XFA PDF document using C# programmatically
1. Create a new C# console application project.
2. Install the Syncfusion.PDF.WinForms NuGet packages as a reference to your .NET Framework application from NuGet.org.
3. Include the following namespaces in the Program.cs file.
C#
using Syncfusion.Pdf.Xfa;
VB.NET
Imports Syncfusion.Pdf.Xfa
4. The following code example shows how to export the XFA data from an existing XFA PDF document using C#.
C#
//Load a PDF document PdfLoadedXfaDocument loadedDocument = new PdfLoadedXfaDocument(@"../../Data/XfaForm.pdf"); //Load the existing XFA form PdfLoadedXfaForm loadedForm = loadedDocument.XfaForm; //Export the XFA data loadedForm.ExportXfaData(@"../../Test.xml");
VB.NET
'Load a PDF document Dim loadedDocument As PdfLoadedXfaDocument = New PdfLoadedXfaDocument("../../Data/XfaForm.pdf") 'Load the existing XFA form Dim loadedForm As PdfLoadedXfaForm = loadedDocument.XfaForm 'Export the XFA data loadedForm.ExportXfaData("../../Test.xml")
A complete working sample can be downloaded from Export_XFAData.zip.
By executing the program, you will get the XML file as follows.
Refer to this link to explore a rich set of Syncfusion Essential® PDF features.
Starting with v16.2.0.x, if you reference Syncfusion® assemblies from the trial setup or NuGet feed, include a license key in your projects. Refer to this link to learn about generating and registering the Syncfusion® license key in your application to use the components without trail message.
See Also:
https://help.syncfusion.com/file-formats/pdf/working-with-xfa
https://www.syncfusion.com/kb/10372/how-to-fill-the-xfa-form-fields-in-c-and-vb-net
https://www.syncfusion.com/kb/10371/how-to-flatten-the-xfa-form-fields-in-c-and-vb-net