JodConverter 错误 officeHome 未设置且无法自动检测
JodConverter Error officeHome not set and could not be auto-detected
我正在尝试使用 libre office 设置 jodconverter。当我尝试使用它时出现此错误:officeHome 未设置且无法自动检测。
我将 Office 设置为主页,但它仍然出现。下面是我如何设置它。谁能建议我在这里做错了什么。
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);
}
}
你应该这样初始化管理器:
final LocalOfficeManager officeManager =
LocalOfficeManager.builder().officeHome("/opt/libreoffice6.0").install().build();
LocalOfficeManager.install() 只会创建一个默认管理器,它将尝试自动检测办公室安装。所以你实际使用的管理器不是你用自定义办公室主目录初始化的管理器。
我正在尝试使用 libre office 设置 jodconverter。当我尝试使用它时出现此错误:officeHome 未设置且无法自动检测。
我将 Office 设置为主页,但它仍然出现。下面是我如何设置它。谁能建议我在这里做错了什么。
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);
}
}
你应该这样初始化管理器:
final LocalOfficeManager officeManager =
LocalOfficeManager.builder().officeHome("/opt/libreoffice6.0").install().build();
LocalOfficeManager.install() 只会创建一个默认管理器,它将尝试自动检测办公室安装。所以你实际使用的管理器不是你用自定义办公室主目录初始化的管理器。