2016-03-09 54 views
0

我有一個Java應用程序,它創建了一些.doc(不是.docx!沒有HTML內部)我需要打印的文檔。打印.doc(不docx)沒有打開Word JAVA

運行程序的PC必須打印所有以這種方式創建的文檔,但沒有在該機器上安裝MS Word,也無法安裝它(或OpenOffice或其他)。

有沒有辦法直接發送給打印機?

感謝

回答

0

您可以直接發送文件的打印機打印隊列中使用任何打印API的一個Microsoft Word文檔。您可能需要檢查OpenOffice DocumentPrinter API。

查看樣品代碼here

 // 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)