Are there any open source or commercial API available to print word document from Java application?
-
Print from a server? What does this mean, render to HTML? – Matthew Flaschen Jun 17 '10 at 02:19
-
1Send to printer from Tomcat server. – Venkat Sadasivam Jun 17 '10 at 02:23
-
Java web server? Do you mean a servlet? Or just a Java desktop app? Please add more information to your question. – Jeff Jun 17 '10 at 02:24
-
You want to print to a printer that is attached to the same computer that is running Tomcat? Or you want a client to print a Word document that your Tomcat server sends to them? If the latter, why not just serve the Word document directly? – Jeff Jun 17 '10 at 02:26
-
I want to print to a printer that is attached to the same computer that is running Tomcat. – Venkat Sadasivam Jun 17 '10 at 02:29
-
forgot to answer other question: it is a servlet application. – Venkat Sadasivam Jun 17 '10 at 02:30
2 Answers
I think you might be able to do it from the command line. Look here: http://fvue.nl/wiki/ClassExec#Printing
You might also want to look at this How can I print Office documents from .NET in a uniform manner?
yet another possibility is to use OpenOffice to print from the command line.
"C:\Program Files\OpenOffice.org 2.3\program\soffice.exe" -pt "Lexmark T640 (MS)" "c:\word_documents\AAA_TEST_DMHM_53317_696198.doc"

- 1
- 1

- 24,113
- 5
- 60
- 79
In order to print a *.doc or *.docx file, you need an application that renders the document with max fidelity, and only Microsoft Word can do that. While there are APIs that let you open the document and extract content, it does not seem this is helpful to you.
This leaves you with only one option - COM automation. There are commercial products for this, there may be free ones too. Here is an example.
A warning: Office automation on a Web server has traditionally been a cumbersome thing to do. It is resource-intensive and unstable. I would try to design around it (i.e. see if you can change the document format, or they way it is created, or the business process).

- 37,019
- 22
- 105
- 153
-
Agree with your comments. But unfortunately not many solution in the world as simple as Microsoft Word. I am even ready buy a commercial reliable API to retain the word document reporting power in our system. – Venkat Sadasivam Jun 18 '10 at 00:14
-
marking this answer as right one, since there no other better way to do. – Venkat Sadasivam Jun 18 '10 at 00:21