I am trying to convert excel file into PDF file in wicket 8 application by using these below APIs. But PDF file is not converting into excel file and I am getting that same excel file on the PDF download link instead of PDF file and there is no exception or error on convert() method.
<dependency>
<groupId>net.sf.jodconverter</groupId>
<artifactId>jodconverter</artifactId>
<version>3.0-beta-4</version>
</dependency>
or
<dependency>
<groupId>com.artofsolving</groupId>
<artifactId>jodconverter</artifactId>
<version>2.2.1</version>
</dependency>
Using this below code to convert excel file to PDF file
public File convertToPDFFile(ByteArrayOutputStream fromExcelFile, String sheetName, OOConfig ooConfig, FileFormat fileFormat) throws Exception {
File tempFile = null;
File resultPDFFile = null;
try {
tempFile = File.createTempFile(sheetName, fileFormat.getFileExtension());
tempFile.setWritable(true);
FileOutputStream fout = new FileOutputStream(tempFile);
fromExcelFile.writeTo(fout);
ExternalOfficeManagerConfiguration eomcTest = new ExternalOfficeManagerConfiguration();
eomcTest.setConnectOnStart(true);
eomcTest.setConnectionProtocol("SOCKET");
eomcTest.setPortNumber(8100);
OfficeManager officeManager = eomcTest.buildOfficeManager();
officeManager.start();
OfficeDocumentConverter officeDocConverter = new OfficeDocumentConverter(officeManager);
resultPDFFile = File.createTempFile(sheetName, TypeOfFile.PDF.getFileExtension());
officeDocConverter.convert(tempFile, resultPDFFile);
fout.close();
officeManager.stop();
} catch (Exception e) {
e.printStackTrace();
} finally {
if (tempFile != null) {
tempFile.delete();
tempFile = null;
}
}
return resultPDFFile;
}
Kindly anyone let me know why jodconverter not converting excel file into pdf file.
Any suggestions will be highly appreciable.
question from:
https://stackoverflow.com/questions/65942921/org-artofsolving-jodconverter-api-not-converting-excel-file-into-pdf-file-in-wic 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…