简体   繁体   English

使用Java打印文档文件

[英]Print a doc file using java

I want to print a doc file using java. 我想使用Java打印文档文件。 How can i do it without any 3rd party API. 没有任何第三方API怎么办?

As far as i know, you have to render the doc file as image and then pass it to the printer. 据我所知,您必须将doc文件渲染为图像,然后将其传递给打印机。 Is there any way to render the doc file in image and then print it? 有什么方法可以在图像中渲染doc文件然后进行打印?

You need not convert the document to an image. 您无需将文档转换为图像。 If you are using Java 6+, you can try: 如果您使用的是Java 6+,则可以尝试:

File file = new File("C:\\document.doc");
Desktop.getDesktop().print(file);

The method print in the class java.awt.Desktop : 该方法在类java.awt.Desktop print

Prints a file with the native desktop printing facility, using the associated application's print command. 使用关联的应用程序的打印命令,通过本机桌面打印工具打印文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM