I need to be able to generate a Word document in my servlet. I've looked around but haven't found much that seems to do what I need. The most promising one seemed to be Apache's POI (http://poi.apache.org/) but the Word part of it doesn't seem to be able to write Word documents the way I need it to.
Ideally, here's what I'd like to do: First I'd have a Word document that would act as a "template". It would look like the paper form we're replacing but would have some unique strings in each field where user would normally have written something.
In my servlet I would read in the "template" file and use the request parameters to replace the unique strings in the fields. Then I would write out the modified Word document to another file.
Seems simple enough but I'm not able to find anything that can do this. I would greatly appreciate any hints/suggestions on how to do this.
Actually, the final goal is to take the new Word file and generate a PDF out of it for future retention in our record retention software. That software only accepts PDFs. I chose Word as the intermediate format because it seemed to be the best way to generate a file that most closely resembled the paper form that's being replaced. If anyone has a better way to do this I'd love to hear it.
The main thing is that I'd like to use open source software to accomplish this. I don't think I can get approval to buy more software at this point.
If the Word is not mandatory for this process it is best to use JasperReports api. First you have to create japser template, best to do this with iReport tool [http://jasperforge.org/plugins/project/project_home.php?group_id=83]. Then for each new report you fill the template with appropriate values. At the end you print that report in PDF format.