Issue with JODConverter and running LibreOffice in headless mode

andunslg picture andunslg · Aug 16, 2013 · Viewed 7.4k times · Source

I am using the following code to convert .doc to .pdf using JOD.

File inputFile = new File("document.doc");
File outputFile = new File("document.pdf");

// connect to an OpenOffice.org instance running on port 8100
OpenOfficeConnection connection = new SocketOpenOfficeConnection(8100);
connection.connect();

// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
converter.convert(inputFile, outputFile);

// close the connection
connection.disconnect();

But I have to run

soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard

separately to start LibreOffice in headless mode.

Is there a way to start LibreOffice programmatically? Or, can't we just give the path to LibreOffice folder to JOD to do the conversion?

Answer

Lars Noschinski picture Lars Noschinski · Sep 18, 2014

You don't need JOD at all to convert a doc file to a PDF. This can be directly done with LibreOffice:

libreoffice --headless --convert-to pdf document.doc