I have a servlet that displays a list of Customers. I want a button on each entry that will call another servlet that will take info about that customer and do something like "mailmerge" with a MS WORD document. Then automatically print that WORD doc. I don't want to open the document for viewing, just want it to print with the database info merged into the document. It can print off of the server since all of the clients are in the same office. The database is also on the server as is the MS word file. So, how can I merge data into the WORD doc and then have it automatically print? TIA Walk Good
The only reasonable way to do mail merge with a Word document is via COM. You can use COM from Java via several third-party APIs (eg, J-Integra or JACOB), but that would require Windows and Word installed somewhere you can get to. To print, you'd still want COM talking to Word. You want to print it on the client, or the server? If the client, a digitally signed applet may be possible. If the server, then you can write Java code directly in the servlet itself. For Word COM integration, you can find examples with J-Integra for simple stuff... perhaps something in Microsoft's KB for more details.
Joined: Apr 23, 2003
Thanks for the reply. Hmmmmm... that sounds like an ultimate but complicated solution. Right now I need to get something done quickly. Perhaps I will be able to learn the COM solution in the future. I am thinking of two posibilities. One, I somehow create the "DATA" doc required for mail merge, inside the servlet. Then the user opens up the letter or template portion and execute the mail merge using WORD. I don't know what the format of the "DATA" doc looks like. Will read it and display each line to find out. Second, somehow open the template doc and read it while writing a new document to print. Everytime I find the mailmerge "tags" for the data to be substituted I write that line with the database values replacing the tags. Don't know how to actually do that (yet). Any suggestions greatly welcome! Walk Good
subject: "mailmerge" to WORD doc and automatically print?