• Post Reply Bookmark Topic Watch Topic
  • New Topic

Create rtf document based on a template  RSS feed

 
Sunil George
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently I am working on a struts application. As part of the development I want to create letters in .rtf format based on a template. The template is stored in a web server folder. I want to open this document and modify its values by the data base values. I want to create multiple copy of this document based on how many vlues in db. I plan to use iText package for it. I am new to iText. When I searched in web i get helps only creating documents from scratch. No examples get where the documents are reading and replacing values with java objects. Could anyone help me on this. I want know how could i read the exising document and replace the document contents by values in java objects.

Thanks in advance,
Sunil George
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
iText can only write RTF files, not read them.

You may need to parse the RTF files yourself, and insert data at the appropriate locations. If you can get away with just using the simple parts of RTF, this may not be very difficult.

If, on the other hand, you need to support the full range of RTF, you could look into the JavaCC parser generator, which comes with an RTF grammar.
 
Sunil George
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it ok using Jakarta POI for read/write the document?
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
POI can read and write XLS and DOC files, so using RTF would not be possible. The DOC support of POI is no longer maintained, though, but for not-too-complex documents it should work fine.
 
Jayantilal Gosar
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://radio.javaranch.com/val/2004/10/16/1097909528000.html
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!