9.11.  Extract XFA Data to XML

Using the utility ExtractXFAData you can export XFA data from a PDF document and use it in XPath based tests as described in section 3.30: “XFA Data”.

Program Start

::
:: Extract XFA data of a PDF document as XML
::

@echo off
setlocal
set CLASSPATH=./lib/pdfunit-2015.10/*;%CLASSPATH%
set CLASSPATH=./lib/itext-5.5.1/*;%CLASSPATH%
set CLASSPATH=./lib/bouncycastle-jdk15on-150/*;%CLASSPATH%

set TOOL=com.pdfunit.tools.ExtractXFAData
set OUT_DIR=./tmp
set IN_FILE=xfa-enabled.pdf
set PASSWD=

java  %TOOL%  %IN_FILE%  %OUT_DIR%  %PASSWD%
endlocal

Input

The input file for the script is xfa-enabled.pdf, a sample document from iText.

Output

The output XML file _xfadata_xfa-enabled.out.xml is quite long. To get a better impression of the generated code, some of the XML-Tags in the next picture are folded:

Internally the extraction program uses the method XfaForm.getDomDocument() from the iText (http://www.itextpdf.com) project.