File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Java in General and the fly likes how to print a word document in java? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "how to print a word document in java?" Watch "how to print a word document in java?" New topic

how to print a word document in java?

Umesh Sharma

Joined: Oct 30, 2008
Posts: 3
Hi All,

is it possible in java to write a program that takes an input and sends it printer. I want this specially for word documents.
i already have a program that works for images but not for word documents.
Please guide me, where i am wrong or help me to get some links or code snippets regarding this. Any kind of help will be greatly appreciated.
I have done lot of RnD on this. Like HWPF and But anything simpler is possible or not, i am surprised to find that such a simple thing is so tough in java. Please help.

//program that works for images but not for document is given below

[Nitesh: Added code tags, please UseCodeTags while posting code.]
[ November 01, 2008: Message edited by: Nitesh Kant ]
Nitesh Kant

Joined: Feb 25, 2007
Posts: 1638

Howdy "wicked_yudi112233"!

Welcome to javaranch!
We being a very friendly community, do not have much rules but there is a naming policy that we are very strict about!
Unfortunately, your display name does not follow the policy. Please take a moment to change the same.

Also, this does not seem to be an advanced question, moving it to Java In General (Intermediate). You may get better answers there.

apigee, a better way to API!
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
What is "an input" - an arbitrary file? .doc in particular is not a file format that is generally understood by printers. You will need a piece of software that understands .doc files and can render (and thus print) them.

Apache POI might help a bit if you use it to render a document into a Printable, but that will not work for complex documents, and would be quite a bit of programming effort on your part.

You might look into using OpenOffice as a server component for handling MS Office files. It does have a Java API.
I agree. Here's the link:
subject: how to print a word document in java?
It's not a secret anymore!