Hi, I have a requirement to print word documents from a servlet. The documents are to be printed at the client printer. User selects a printer to print the document. I am struggling to find a way to connct to the word document from servlet. I also have to add watermarks to the word document before printing. Can anybody help me in this regard. Any code examples will be of great help.
There is nothing in the servlet spec for working with PDF. Creating and/or altering them from Java apps is done with 3rd party libraries such as Apache FOP or iText. Inquire in our "Other Open Source Projects" for more information on these libraries.
Printing is something that is handled on the client. The client will need to open the file in a PDF viewer (such as Adobe Acrobat) and print it from there.
LIke Ben says, you won't be able to print to the users printer "from the servlet". Can't you just provide a link to the file, which allows the user to access the document directly, thus allowing him to print it whereever he desires?
As to watermarking a Word document, have a look at the AccessingFileFormats page. The POI, WordApi and (particularly) OpenOffice packages may help with this. [ September 21, 2006: Message edited by: Ulf Dittmer ]