This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

generation of PDF files using .rtf template sample

 
Bindu Padmanabhan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Hi,

I am working on an application, where i need to generate PDF files to send out to the users.

I have a sample .rtf file, which is the template for the PDF files. This template is actually a letter format, in which the fields like name, address, license number etc are marked as @name@, @address@ etc. I have to generate pdf files( actually letters to the users) replacing @name@ ,@address@ etc with the real time name ,address from the database.

Can i use iText API for this? or PDFBox ? I googled but couldn't find much useful info.

Appreciate your advices.

Thanks in advance.
Bindu
 
Tim Moores
Bartender
Posts: 2790
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out JODConverter - it uses OpenOffice in server mode to convert between various formats; it should be handle RTF to PDF. The text replacement before that can be done using a tool like sed.
 
Bindu Padmanabhan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your quick reply. Do you have any idea, is this possible through iText?
 
Tim Moores
Bartender
Posts: 2790
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure it's possible. But you'd essentially be writing a RTF-2-PDF converter on your own - that's a LOT of work.
 
Bindu Padmanabhan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot, Tim . So you think JODConverter is the best option? And is the tool 'sed' is integrated with the JODConverter?
And are these 2 opensource??
 
Tim Moores
Bartender
Posts: 2790
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We don't know enough about the circumstances to say what might be the best option; it's what I would check out first.

sed is a tool that's installed on every Unix system in existence; it has nothing to do with JODConverter. Look up its Wikipedia page for the basic facts. But string replacement is easy - you can use any approach you like, including writing your own Java code, or using a Java framework like Velocity or FreeMarker.
 
Bindu Padmanabhan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your patience in answering my questions. I also think Freemarker is a good choice in placeholder replacement.
Let me try with freemarker and JODConverter. Thanks
 
Bindu Padmanabhan
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more quick question. I googled about the use of freemarker. It mainly replaces the placeholders inside ${} . I am wondering whether it can replace strings inside @ @??

Thanks in advance
 
Tim Moores
Bartender
Posts: 2790
38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't think so.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic