繁体   English   中英

不打开Word JAVA即可打印.doc(NOT docx)

[英]Print .doc (NOT docx) without opening Word JAVA

我有一个Java应用程序,它创建了一些需要打印的.doc(不是.docx!内部没有HTML)文档。

将运行该程序的PC必须打印以这种方式创建的所有文档,但是该计算机上未安装MS Word,也无法安装(或openoffice或其他任何工具)。

有没有办法直接将其发送到打印机?

谢谢

您可以通过将文档直接发送到打印机队列来使用任何打印API来打印Microsoft Word文档。 您可能要检查openoffice DocumentPrinter api。

在此处检查示例代码。

        // Setting the property "Name" for the favoured printer (name of
        // IP address)
        com.sun.star.beans.PropertyValue propertyValue[] =
            new com.sun.star.beans.PropertyValue[1];
        propertyValue[0] = new com.sun.star.beans.PropertyValue();
        propertyValue[0].Name = "Name";
        propertyValue[0].Value = args[ 0 ];

        // Setting the name of the printer
        xPrintable.setPrinter( propertyValue );

        // Setting the property "Pages" so that only the desired pages
        // will be printed.
        propertyValue[0] = new com.sun.star.beans.PropertyValue();
        propertyValue[0].Name = "Pages";
        propertyValue[0].Value = args[ 2 ];

        // Printing the loaded document
        xPrintable.print( propertyValue )

暂无
暂无

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

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