9.3.  Extract Field Information to XML

The program ExtractFieldInfo creates an XML file with numerous items of information on many properties of all form fields. You can use the extracted data to reveal properties of the fields. The content of a field is not extracted!

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

Program Start

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

@echo off
setlocal
set CLASSPATH=./lib/aspectj-1.8.7/*;%CLASSPATH%
set CLASSPATH=./lib/bouncycastle-jdk15on-153/*;%CLASSPATH%
set CLASSPATH=./lib/commons-logging-1.2/*;%CLASSPATH%
set CLASSPATH=./lib/commons-collections4-4.1/*;%CLASSPATH%
set CLASSPATH=./lib/pdfbox-2.0.0/*;%CLASSPATH%
set CLASSPATH=./lib/pdfunit-2016.05/*;%CLASSPATH%

set TOOL=com.pdfunit.tools.ExtractFieldInfo
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"?>
<fields>
  <!-- Width and height values are given as millimeters, rounded to integers. -->
  <field fieldName="ageField"      type="TEXT"             
         fieldHeight="8.0"         fieldWidth="11.0" 
         isChecked="false"         isEditable="true" 
         isExportable="true"       isMultiLineField="false"
         isMultiSelectable="false" isPasswordField="false" 
         isRequired="false"        isSigned="false" 
         isVisibleInPrint="true"   isVisibleOnScreen="true" 
         page="1"                  positionOnPage="[x:105.0, y=59.0]" 
  />
  <field fieldName="nameField"     type="TEXT"
         fieldHeight="8.0"         fieldWidth="71.0" 
         isChecked="false"         isEditable="true" 
         isExportable="true"       isMultiLineField="false"
         isMultiSelectable="false" isPasswordField="false" 
         isRequired="true"         isSigned="false" 
         isVisibleInPrint="true"   isVisibleOnScreen="true" 
         page="1"                  positionOnPage="[x:105.0, y=51.0]"
  />
  <!-- 3 fields deleted for presentation -->
</fields>