我正在尝试使用libre office设置jodconverter。当我尝试使用它时,我收到此错误:officeHome未设置,无法自动检测。
我把办公室安置回家,但现在还在。以下是我如何设置它。任何人都可以告诉我这里做错了什么。public void convert(){
File inputFile = new File("SippKey.rtf");
File outputFile = new File("SippKeyCon.html");
LocalOfficeManager.builder().officeHome("/opt/libreoffice6.0").build();
final LocalOfficeManager officeManager = LocalOfficeManager.install();
try {
// Start an office process and connect to the started instance (on port
2002).
officeManager.start();
// Convert
JodConverter
.convert(inputFile)
.to(outputFile)
.execute();
} catch (OfficeException ex) {
// ex.printStackTrace();
Logger.getLogger(QrGUI.class.getName()).log(Level.SEVERE, null,
ex);
} finally {
// Stop the office process
OfficeUtils.stopQuietly(officeManager);
}
}
答案 0 :(得分:0)
您应该以这种方式初始化经理:
final LocalOfficeManager officeManager =
LocalOfficeManager.builder().officeHome("/opt/libreoffice6.0").install().build();
LocalOfficeManager.install()将只创建一个默认管理器,它将尝试自动检测办公室安装。因此,您实际使用的管理器不是您使用自定义办公室主目录初始化的管理器。