9.3.  Extract Field Information to XML

The program ExtractFieldsInfo creates an XML file with numerous items of information about many properties of all form fields. The content of a field is not extracted!

Testing field properties is described in chapter 3.10: “Form Fields”.

Program Start

::
:: Extract formular fields from a PDF document into an XML file
::

@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.ExtractFieldsInfo
set OUT_DIR=./tmp
set IN_FILE=javaScriptForFields.pdf
set PASSWD=

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

Input

The input file javaScriptForFields.pdf is a sample containing 3 input fields and 2 buttons:

Output

And this is a snippet of the generated file _fieldinfo_javaScriptForFields.out.xml:

<?xml version="1.0" encoding="UTF-8" ?>
<fieldlist>
  <!-- Width and height values are given as millimeters. -->             
  <field name="ageField"                   type="text" 
         width="30"                        height="22"                  1 
         isEditable="true"                 isRequired="false" 
         isPrintable="false"               isVisible="false" 
         isHidden="false"                  isHiddenButPrintable="false" 
         isVisibleButNotPrintable="false"  isExportable="true"
         isPasswordField="false"           isMultiLineField="false"     2 
  />
  <field name="reset"                      type="button" 
         width="35"                        height="15" 
         isEditable="true"                 isRequired="true" 
         isPrintable="false"               isVisible="false" 
         isHidden="false"                  isHiddenButPrintable="true" 
         isVisibleButNotPrintable="true"   isExportable="true"          3 
  />
  <!-- 3 fields deleted for presentation -->
</fieldlist>

1

Values for width and height are given in millimeters

2 3

Some attributes are created type dependent. For example the attribute isMultiLineField does not makes sense for fields of type button.