Tuesday, November 16, 2004

PDF file creation: iText

iText is a free Java class library to create PDF files.

Features:

Below is a simple bar code example taken from the documentation:

PdfContentByte cb = writer.getDirectContent();
BarcodeEAN codeEAN = new BarcodeEAN();
codeEAN.setCodeType(codeEAN.EAN13);
codeEAN.setCode("9780201615883");
Image imageEAN = codeEAN.createImageWithBarcode(cb, null, null);
document.add(new Phrase(new Chunk(imageEAN, 0, 0)));


ThereĀ“s also an iText ant task (from the Fopps project) which takes an XML file as input and generates a PDF file (HTML and RTF are also supported).
Below is an example, which builds a pdf document out of plain.xml. Every page contains the header 'My header' and the footer 'Page x of y':


<itext
src="Plain.xml"
dest="Test1.pdf"
header="My header"
footer="pagenumbering">
</itext>

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home