JodConverter Error :officeHome not set and could not be auto-detected

 原问题:

I am trying to set up jodconverter using libre office. when i try to use it i get this error: officeHome not set and could not be auto-detected.

I set office home but this is still coming up. Below is how I have it set up. Can anyone advise what I am doing wrong here.

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);
    }
}

解答:

You should initialize the manager this way:

final LocalOfficeManager officeManager = 
    LocalOfficeManager.builder().officeHome("/opt/libreoffice6.0").install().build();

LocalOfficeManager.install() will just create a default manager which will try to autodetect the office installation. So the manager you are actually using is not the one you initialized with the custom office home directory. 

注意:需要先安装 openOffice 环境。否则无法注入相应的 Bean,如 localOfficeManager 等。

原链接:https://stackoverflow.com/questions/50474587/jodconverter-error-officehome-not-set-and-could-not-be-auto-detected

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值