1

I have upgraded my application from Wicket 1.x to 8.x version.

I am facing an issue to convert Excel file into PDF format.

Using this below dependencies:

<dependency>
    <groupId>net.sf.jodconverter</groupId>
    <artifactId>jodconverter</artifactId>
    <version>3.0-beta-4</version>
</dependency>

Using these import classes

import org.artofsolving.jodconverter.OfficeDocumentConverter;
import org.artofsolving.jodconverter.office.ExternalOfficeManagerConfiguration;
import org.artofsolving.jodconverter.office.OfficeConnectionProtocol;
import org.artofsolving.jodconverter.office.OfficeManager;

Getting this below error on this line while calling buildOfficeManager() method.

OfficeManager officeManager = eomc.buildOfficeManager();

I am getting this below exception on this above line:

java.lang.ClassNotFoundException: com.sun.star.connection.NoConnectException at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1358) at org.apache.catalina.loader.WebappClassLoaderBase.loadClass(WebappClassLoaderBase.java:1180) at org.artofsolving.jodconverter.office.ExternalOfficeManager.(ExternalOfficeManager.java:55) at org.artofsolving.jodconverter.office.ExternalOfficeManagerConfiguration.buildOfficeManager(ExternalOfficeManagerConfiguration.java:50)

Using below system parameters:

[openofficeHome=C:/Program Files/openoffice.org3, hostname=127.0.0.1, port=8100, protocol=SOCKET]

Below is the more detail of code:

ExternalOfficeManagerConfiguration eomcTest = new ExternalOfficeManagerConfiguration();
eomcTest.setConnectOnStart(true);

eomcTest.setConnectionProtocol(ooConfig.getProtocol());

if (OfficeConnectionProtocol.PIPE.equals(ooConfig.getProtocol())) {
    eomcTest.setPipeName("officePipe");
} else {
    eomcTest.setPortNumber(ooConfig.getPort());
}

OfficeManager officeManager = eomcTest.buildOfficeManager();
officeManager.start();
OfficeDocumentConverter officeDocConverter = new OfficeDocumentConverter(officeManager);
resultFile = File.createTempFile(sheetName, TypeOfFile.PDF.getFileExtension());
officeDocConverter.convert(tempFile, resultFile);
fout.close();
officeManager.stop();

Kindly anyone let me know why buildOfficeManager() is giving error here and what can be the solution here to resolve this issue. It will be more appreciable.

martin-g
  • 17,243
  • 2
  • 23
  • 35
user3552342
  • 657
  • 1
  • 5
  • 14

2 Answers2

2

According to https://search.maven.org/search?q=fc:com.sun.star.connection.NoConnectException you need to add org.libreoffice:libreoffice (or the old org.libreoffice:ridl) dependency to Maven's pom.xml.

I don't see net.sf.jodconverter at https://search.maven.org/search?q=jodconverter. You may try with a more recent version of it - probably any of the listed ones here: https://search.maven.org/search?q=g:org.jodconverter

martin-g
  • 17,243
  • 2
  • 23
  • 35
  • In my project using OpenOffice in production so need to configure with OpenOffice. Now OpenOffice is connecting with Jodconverter API without any error in the server but Excel file is not converting to the PDF file and getting excel file on PDF download click and there is no error on the console. – user3552342 Jan 28 '21 at 16:00
  • I am able to convert excel file into pdf file in the local system by using this class "org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration" and for server, I am using class "org.artofsolving.jodconverter.office.ExternalOfficeManagerConfiguration" but on server it is not converting the file into pdf. Any suggestion why the openOffice is not converting file on the server. – user3552342 Feb 03 '21 at 15:35
  • Hi @martin, please vote for this question. Hope this can help others to resolve their issues. – user3552342 Mar 10 '21 at 19:26
0

I have resolved this issue and above code is working fine to convert excel file into pdf file with jodconverter API.

In my case, excel file and pdf file both were having the same name which was causing the issue to return the same excel file on pdf download link. After a change in pdf's name, it resolved my issue.

user3552342
  • 657
  • 1
  • 5
  • 14