wood burning stoves 2.0*
The moose likes Other Open Source Projects and the fly likes Servlet To Print Ms-Word files on client side Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "Servlet To Print Ms-Word files on client side" Watch "Servlet To Print Ms-Word files on client side" New topic
Author

Servlet To Print Ms-Word files on client side

amarshi mohanty
Ranch Hand

Joined: Jul 01, 2008
Posts: 110
Hi All,
I am looking for a code to print ms-word side using a servlet in client machine.
If any code or example or sugegstings available,please share...


Thanks
Amarshi


SCJP (97%), SCWCD (95%))
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

You can find a list of libraries available to write a Word file (or other formats) here...


SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
amarshi mohanty
Ranch Hand

Joined: Jul 01, 2008
Posts: 110
Thanks Ankit for the fast reply.
I also read that poi can solve the problem..but I m not getting how it will work.do you have any links avail.


Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

There are examples of the use of POI here...
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41635
    
  55
Nothing a servlet does can cause a file to be printed on the client side. (And POI has no provisions for printing to begin with.) Why can't the user decide whether or not to print a document?


Ping & DNS - my free Android networking tools app
amarshi mohanty
Ranch Hand

Joined: Jul 01, 2008
Posts: 110
Well the user has to click a print button and the word.doc will be moved to printer for printing without displaying on the browser.
My code is working on server side not in client side.
Someway i need to use javascript to allow the printing.
But i am not findng any javascript method avail in the existing .class file that i can use to invoke at runtime.


Amarshi
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41635
    
  55
JavaScript can be used to invoke the "print" method that will cause the print dialog to pop up for the current web page, but it has no provisions for printing any other kind of document.

Note that the web app being allowed to print documents on the client without any user interaction would be a bad security risk; that's why it's not possible.
amarshi mohanty
Ranch Hand

Joined: Jul 01, 2008
Posts: 110
But i am able to print pdf file directly to printer:
pdfCopy.addJavaScript("this.print({bUI: false, bSilent: true, bShrinkToFit: true});",false);


so some way has to be there to do the same with word.'
Conversion to .pdf from word will be the last idea.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41635
    
  55
so some way has to be there to do the same with word.

Why? PDF is very different from DOC.
amarshi mohanty
Ranch Hand

Joined: Jul 01, 2008
Posts: 110
PDF is not a MS file.
for pdf there is iText.jar which provides all the manupilations.But less info is available for handling ms-word file using POI.jar
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Servlet To Print Ms-Word files on client side