With ByteScout PDF Extractor SDK, you can convert PDF XFA Form to XML. Check the code samples in C#, VB.NET and VBScript below.
Select your programming language:
using System; using Bytescout.PDFExtractor; namespace XFAFormToXML { class Program { static void Main(string[] args) { // Create Bytescout.PDFExtractor.XFAFormExtractor instance XFAFormExtractor extractor = new XFAFormExtractor(); extractor.RegistrationName = "demo"; extractor.RegistrationKey = "demo"; // Load sample PDF document extractor.LoadDocumentFromFile("samplexfa.pdf"); // Enumerate XFA form content part types foreach (XFAFormContentType contentType in Enum.GetValues(typeof(XFAFormContentType))) { // Get count of content parts of specified type int partCount = extractor.GetCount(contentType); // Save parts as XML files for (int i = 0; i < partCount; i++) { string fileName = contentType.ToString() + i + ".xml"; extractor.SaveToFile(contentType, i, fileName); Console.WriteLine("Saved form part " + fileName); } } Console.WriteLine(); Console.WriteLine("Press any key to continue..."); Console.ReadLine(); } } }
Imports Bytescout.PDFExtractor Class Program Friend Shared Sub Main(args As String()) ' Create Bytescout.PDFExtractor.XFAFormExtractor instance Dim extractor As New XFAFormExtractor() extractor.RegistrationName = "demo" extractor.RegistrationKey = "demo" ' Load sample PDF document extractor.LoadDocumentFromFile("samplexfa.pdf") ' Enumerate XFA form content part types For Each contentType As XFAFormContentType In [Enum].GetValues(GetType(XFAFormContentType)) 'Get count of content parts of specified type Dim partCount As Integer = extractor.GetCount(contentType) ' Save parts as XML files For i As Integer = 0 To partCount - 1 Dim fileName As String = contentType.ToString() + i.ToString() + ".xml" extractor.SaveToFile(contentType, i, fileName) Console.WriteLine("Saved form part " + fileName) Next Next Console.WriteLine() Console.WriteLine("Press any key to continue...") Console.ReadLine() End Sub End Class
' Create Bytescout.PDFExtractor.XMLExtractor object Set extractor = CreateObject("Bytescout.PDFExtractor.XFAFormExtractor") extractor.RegistrationName = "demo" extractor.RegistrationKey = "demo" ' Load sample PDF document extractor.LoadDocumentFromFile "..\..\samplexfa.pdf" for i=0 to 12 ' iterate through 12 content types (see XFAFormContentType enum in the documentation, there are 13 types) count = extractor.GetCount(i) ' get count of the given type For j=0 to count-1 extractor.SaveToFile i, j, CStr(i) & "-" & CStr(j) & ".xml" Next Next MsgBox "XFA xml data has been extracted"