开发者

Generating letters in Java [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopen开发者_高级运维ed, visit the help center for guidance. Closed 10 years ago.

I need to generate some business letters in Java, with some dynamic information like address, to,from etc. Remaining letter content would be the same. These letters are not displayed to the user but are directly printed. I know i can do this using Jasper Reports i.e generate pdf & print it. Does somebody have any other suggestions for this?


You could use a PDF-tool like iText. iText lets you create pdf documents from Java or .NET.


FreeMarker is perfect for the generation. You would probably then use some other library to convert to a printable format and print.


If you want to create PDFs, I recommend Apache PDFBox. Examples are available here.


If you're up to it, you can use a few freely available libraries to construct your own system where the user can provide the templates in a Word (or Writer) format. Several options are available to do the merging of data with the template but basically it comes down to opening the document as xml and replacing custom tags (or the ones used for the mailmerge function) with the data. You could implement FreeMarker for the custom tags (see Mike's answer). Libraries that cross my mind are:

  • OpenOffice API
  • Docx4J
  • Apache POI

There are plenty of experienced users here on SO for these (and other libraries) so any problem you encounter will surely get a decent followup.

Cheers, Wim


In answer to your template comments, JODReports or Docmosis might be useful. They work over top of the OpenOffice API (as per Wivani's response) which can be hard to use directly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜