I'm trying to get JODConverter to work on Window 10 with Jdk 1.8.0_144. As you can see from the code I thought it might be a timing issue hence the delay. As you can see JODConverter thinks the OfficeManager is running. I'm using the follow code:
import java.io.File;
import org.jodconverter.JodConverter;
import org.jodconverter.office.LocalOfficeManager;
import org.jodconverter.office.OfficeException;
import org.jodconverter.office.OfficeManager;
import org.jodconverter.office.OfficeUtils;
import org.jodconverter.process.ProcessManager;
public class JodConverterTest {
public static void main(String[] args) throws OfficeException, InterruptedException {
OfficeManager officeManager
= LocalOfficeManager.builder()
.officeHome("C:\\Program Files\\LibreOffice")
.portNumbers(2372)
.build();
officeManager.start();
File inputFile = new File("c:\\test\\rtf.rtf");
File outputFile = new File("c:\\test\\rtf.pdf");
try {
System.out.println("officeManager.isRunning()="+officeManager.isRunning());
Thread.sleep(10000);
System.out.println("officeManager.isRunning()="+officeManager.isRunning());
JodConverter.convert(inputFile).to(outputFile).execute();
} finally {
// Stop the office process
OfficeUtils.stopQuietly(officeManager);
}
}
}
I get the following error when I run it:-
officeManager.isRunning()=true
officeManager.isRunning()=true
Exception in thread "main" java.lang.IllegalStateException: An office manager is required in order to build a converter.
at org.jodconverter.job.AbstractConverter.<init>(AbstractConverter.java:57)
at org.jodconverter.LocalConverter.<init>(LocalConverter.java:93)
at org.jodconverter.LocalConverter.<init>(LocalConverter.java:49)
at org.jodconverter.LocalConverter$Builder.build(LocalConverter.java:202)
at org.jodconverter.LocalConverter.make(LocalConverter.java:73)
at org.jodconverter.JodConverter.convert(JodConverter.java:48)
at ZPlaying.JodConverterTest.main(JodConverterTest.java:30)
------------------------------------------------------------------------
BUILD FAILURE
Things I've tried:- - Changing the port number - Researching to see if I can find the classpath of the java Process Manager and adding the following but I couldn't find the classpath of the ProcessManager as I don't really know much about that:- .processManager("com.example.foo.CustomProcessManager") - also wondered whether it is something to do with running via Netbeans?
Here is the applicable maven dependency:-
<dependency>
<groupId>org.jodconverter</groupId>
<artifactId>jodconverter-local</artifactId>
<version>4.1.1</version>
</dependency>
I've installed Libre (fresh install) in C:\Program Files\LibreOffice