GithubHelp home page GithubHelp logo

skeemer / pdfforms-filler-java Goto Github PK

View Code? Open in Web Editor NEW

This project forked from uberboom/pdfforms-filler-java

0.0 2.0 0.0 75 KB

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

License: MIT License

Java 100.00%

pdfforms-filler-java's Introduction

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.