Get it

Get the full distribution (920 KB, contains all you need excluding ant) or get the pure source code (91 KB, source code and examples only)

The source code is covered by the Apache license.

Use it

Description

Ant task to create several document formats out of xml files using the iText framework.

It can be used to create your documentation in several output formats from one source. Currently iText supports PDF (default), HTML and RTF. It also supports your own tag maps, headers and footers. The distribution contains some examples token from the iText website. This site contains also an excellent tutorial.

Installation

You need to put the jar files (itext.jar, itext-xml.jat, itexttask.jar) in into the lib direcory of ant. Then you have to register the itext task in your build file.
	...
		<available property="iTextTask.present"
    		   classname="org.apache.tools.ant.taskdefs.optional.IText"/>
	...
	    		   
	<target name="tdef" depends="prepare" if="iTextTask.present">		
		<taskdef name="iText" classname="org.apache.tools.ant.taskdefs.optional.IText"/>
	</target>    		   

Parameters

The Task has the following attributes:

Attribute Description Required
dest Where to place the generated file. The ending of the file is not taken into account. Yes
srcdir Input file (XML file) to parse. File must exist Yes
format Desired output format ('pdf', 'html' or 'rtf'. Default is 'pdf' No
tagmap Tag map to use No
header Header for every page (PDF only) No
footer Footer for every page. Use 'pagenumbering', if you like to have the page numbers in the footer (PDF only) No

Example

Builds a pdf document without tag map out of plain.xml. Every page contains a header 'My header', the footer 'Page x of y'.
		<iText 
			src="Plain.xml" 
			dest="Test1.pdf" 
			header ="My header"
			footer ="pagenumbering"
		/>
Builds a html document out of WithTags.xml with tag map TagMap.xml. Every page has a footer 'My footer'.
		<iText 
			src="WithTags.xml" 
			dest="${tmp.dir}/Test2.html" 
			tagmap="TagMap.xml"
			footer ="My footer"
			format="html"
		/>
Builds a rtf document out of WithTags.xml with tag map TagMap.xml. Pages have neither a footer nor a header.
		<iText 
			src="src/etc/testcases/taskdefs/optional/WithTags.xml" 
			dest="${tmp.dir}/Test3.rtf" 
			tagmap="src/etc/testcases/taskdefs/optional/TagMap.xml"
			format="rtf"
		/>

Notes

This task is currently not part of the ant distribution, but should obey to their rules. Some of the test cases won't work at this moment, due to problems with the XML parser. Running this task like described above should work fine.