Ubuntu使用JODconverter和openoffice将doc转换为pdf

时间:2014-04-18 07:03:55

标签: java pdf ubuntu

我已经安装了java和openoffice,但是我收到以下错误消息:

root@ubuntu:/var/www/html# java -jar JODConverter/jodconverter-3.0-beta-1.jar test.doc test.pdf
Exception in thread "main" java.lang.IllegalArgumentException: officeHome doesn't exist: /opt/openoffice.org3
at net.sf.jodconverter.office.ManagedOfficeProcess.<init>(ManagedOfficeProcess.java:58)
at net.sf.jodconverter.office.ManagedProcessOfficeManager.<init>(ManagedProcessOfficeManager.java:89)
at net.sf.jodconverter.office.ManagedProcessOfficeManager.<init>(ManagedProcessOfficeManager.java:85)
at net.sf.jodconverter.cli.Convert.getOfficeManager(Convert.java:120)
at net.sf.jodconverter.cli.Convert.main(Convert.java:97)

1 个答案:

答案 0 :(得分:0)

你可以像这样设置officeHome(第二个setter):

// create the officemanager with the given settings
officeManager = new DefaultOfficeManagerConfiguration()
    // either socket or pipe, pipe is faster but requires native libraries
    .setConnectionProtocol(OfficeConnectionProtocol.SOCKET)
    // the installation directory of the openoffice installation
    .setOfficeHome(new File(officeHome))
    // the amount of ports in the array determines how many instances are managed
    .setPortNumbers(portNumbers)
    // after how many tasks the process is restarted as a work around to the known memory leaks in openoffice
    .setMaxTasksPerProcess(maxTasksPerProcess)
    // how long a task can run before it is considered timed out, default is 2 min
    .setTaskExecutionTimeout(taskExecutionTimeout)
    // how long the code waits for a process to become available, default is 30 seconds
    .setTaskQueueTimeout(taskQueueTimeout)
    .buildOfficeManager();