Skip to content

A simple Java command line PDF forms filler using an XML file to set the form values.

License

Notifications You must be signed in to change notification settings

uberboom/pdfforms-filler-java

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Command Line PDF Forms Filler

A simple Java command line PDF forms filler using an XML file to set the form values.

Build the PDF Forms Filler

Use Maven 2 or Maven 3 to build the project:

mvn package

Usage

Parameters

Option Description
--template <templatefile> PDF file with form fields
--target <targetfile> Target PDF file
--xml <xmlfile> XML file containing form values
--fonts <fontspath> Folder containing additional fonts, if required
--verbose Output form field information
--flatten Flatten the form fields

Run the Sample Provided

java -jar target/PdfForms_1.0-jar-with-dependencies.jar --template "sample/formtest.pdf" --xml "sample/fields.xml" --target "sample/formtest.output.pdf" --verbose --fonts "sample"

XML File Format

To pass form values, you have to declare a simple XML file.

<fields>
	<!-- fill a text field with name “Address_1” -->
	<field>
		<key>Address_1</key>
		<type>field</type>
		<readonly>false</readonly>
		<value>Address Line 1</value>
	</field>
	<!-- fill a text field with name “Address_2” and set it to read-only -->
	<field>
		<key>Address_2</key>
		<type>field</type>
		<readonly>true</readonly>
		<value>Address Line 2 Readonly</value>
	</field>
	<!-- enable a checkbox with name “ASSOCIATES DEGREE” -->
	<field>
		<key>ASSOCIATES DEGREE</key>
		<type>field</type>
		<readonly>false</readonly>
		<value>On</value>
	</field>
	<!-- set a radio with name “Sex” to value “FEMALE” -->
	<field>
		<key>Sex</key>
		<type>field</type>
		<readonly>false</readonly>
		<value>FEMALE</value>
	</field>
	<!-- add a text using a custom font -->
	<field>
		<key/>
		<type>text</type>
		<readonly>false</readonly>
		<value>ABCDEF</value>
		<config>
			<size>50</size>
			<x>57</x>
			<y>780</y>
			<font>code_128.ttf</font>
		</config>
	</field>
</fields>

License

Please note that the “PDF Forms Filler” is using the iText library, which requires you to buy a commercial license as soon as you develop activities involving the iText software without disclosing the source code of your own applications.

Todo

  • Provide jUnit tests.

About

A simple Java command line PDF forms filler using an XML file to set the form values.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages