• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

Create rtf document based on a template

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is it ok using Jakarta POI for read/write the document?
 
Ulf Dittmer
Rancher
Posts: 43028
76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://radio.javaranch.com/val/2004/10/16/1097909528000.html
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic