0

I am trying to convert office file to pdf using JODConveter. i have followed all the steps present in [this link]http://www.artofsolving.com/node/14.html

but it is showing error. enter image description here

Sangram Badi
  • 4,054
  • 9
  • 45
  • 78

1 Answers1

0

1st need to set the path variable of Open office, then open cmd with open office installed location then run a command

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

Use this code in your java project:

OpenOfficeConnection connection = new SocketOpenOfficeConnection("localhost",8100);

            try {
                connection.connect();
                long t1 = System.currentTimeMillis();
                DocumentConverter converter = new OpenOfficeDocumentConverter(connection);

                converter.convert(inputFile, outputFileLoacation);
                long t2 = System.currentTimeMillis();
                System.out.println(input + " =  " + (t2 - t1) + " ms");

            } catch (ConnectException e) {
                e.printStackTrace();
            } finally {
                if (connection.isConnected()) {
                    connection.disconnect();
                }
Sangram Badi
  • 4,054
  • 9
  • 45
  • 78