Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
The moose likes Other Open Source Projects and the fly likes iText and template. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "iText and template." Watch "iText and template." New topic

iText and template.

Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
I have not worked with iText much, but I have a question regarding iText.
Does iText support some sort of template file , so that we can merge template and data objects at runtime to generate the pdf.

Rahul Bhattacharjee
LinkedIn - Blog
Bruno Lowagie
Ranch Hand

Joined: Oct 23, 2006
Posts: 88
Originally posted by Rahul Bhattacharjee:
Does iText support some sort of template file

You could use a PDF document containing an AcroForm, then use iText to fill in the fields that are inside this form. If you have a PDF without these AcroFields, you could still use PdfStamper to add text or images (a watermark) at specific coordinates on the page. There's also an example in the book (chapter 14) where I have a letter in XML with some empty tags that should be replaced by a name, an address,... In the real world I use this technique to create a document with 27,000 pages. Each page is an invoice for the students of Ghent University with a detailled descriptions of the different study programs he or she has subscribed too.

Note that PDF is not a format that is suitable for editing! PDF is a Page Definition Language (PDF), not a Word processing format.
Rahul Bhattacharjee
Ranch Hand

Joined: Nov 29, 2005
Posts: 2308
This suffices my requirement.
I agree. Here's the link:
subject: iText and template.
It's not a secret anymore!