0
最近,我正在研究一個可以在Netbeans中打印DOCX文件的項目。我是java新手,所以我不太熟悉它。我使用Aspose.Words,但我真的不知道如何使用它。我看了很多教程,但他們不在NetBeans中,所以我很困惑。非常感謝您的幫助。如何使用Aspose.words在Netbeans中打印DOCX文件?
這是我的代碼:
String dox = path.getText();
XWPFDocument docx = null;
try {
docx = new XWPFDocument(POIXMLDocument.openPackage(dox));
XWPFWordExtractor ext = new XWPFWordExtractor(docx);
content.setText(ext.getText());
} catch (IOException ex) {
Logger.getLogger(count.class.getName()).log(Level.SEVERE, null, ex);
}
PrinterJob job = PrinterJob.getPrinterJob();
job.setPrintable(new OutputPrinter(path.getText()));
boolean doPrint = job.printDialog();
if (doPrint)
{
try
{
job.print();
}
catch (PrinterException e)
{
// Print job did not complete.
}
}
我試圖提取它,但它只是獲取內容。我正在嘗試打印整個文檔,就像在MSWord中一樣。