• 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
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Printing word documents from Servlet

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Abhijit Sontakey
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for the reply. However i have to manipulate word documents and print word documents at the printer selected by the user. itext and FoP are only for PDFs not for Word.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Other Open Source Projects, where I will give you a couple links I've run into.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This tutorial page from the iText documentation site:
http://itextdocs.lowagie.com/tutorial/general/webapp/
has example code for a servlet that 'silently' prints a PDF:
http://itextdocs.lowagie.com/examples/com/lowagie/examples/general/webapp/SilentPrintServlet.java

I haven't tried it but it might be just what you're looking for.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Space pants. Tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic