I'm trying to convert documents(.docx/.xlsx/.pptx) to PDF using JOD Converter. I'm using OpenOffice 4.1.2 on Centos 7. My problem is, I'm getting constant CPU usage of 100% while i'm converting the file, and this is impacting the performance of overall machine. I have tried every possible option in the command line options, but ,unfortunately, haven't been able to mitigate this issue. I have searched on a lot of forums, and found that lot of other people are also facing the same problem, however, there is no solution out there. Through my readings, I realize this could be because memory leak problems in OpenOffice. Can someone please help me resolve or at-least mitigate this?
Below is the command that I use to spawn the OpenOffice instance.
/opt/openoffice4/program/soffice.bin -accept=socket,host=127.0.0.1,port=8016;urp; -env:UserInstallation=file:///tmp/.jodconverter_socket_host-127.0.0.1_port-8016 -headless -nocrashreport -nodefault -nofirststartwizard -nolockcheck -nologo -norestore
The code I'm using to convert the files is as follows: package org.samples.docxconverters.jodconverter.pdf;
import java.io.File;
import org.apache.commons.io.FilenameUtils;
import org.artofsolving.jodconverter.OfficeDocumentConverter;
import org.artofsolving.jodconverter.office.DefaultOfficeManagerConfiguration;
import org.artofsolving.jodconverter.office.OfficeManager;
public class Word2PdfJod {
public static void main(String[] args) {
// 1) Start LibreOffice in headless mode.
OfficeManager officeManager = null;
try {
officeManager = new DefaultOfficeManagerConfiguration()
.setOfficeHome(new File("/Applications/OpenOffice.app/Contents/")).buildOfficeManager();
officeManager.start();
// 2) Create JODConverter converter
OfficeDocumentConverter converter = new OfficeDocumentConverter(
officeManager);
// 3) Create PDF
createPDF(converter);
} finally {
// 4) Stop OpenOffice in headless mode.
if (officeManager != null) {
officeManager.stop();
}
}
}
private static void createPDF(OfficeDocumentConverter converter) {
try {
long start = System.currentTimeMillis();
String src_file = "/Users/Aman/Documents/WindowsData/DocumentConversionPoc/Powerpoint2Pdf/JODConverterV3/Sample_pptx_files/AdeemSample2.pptx";
System.out.println(src_file.substring(0, src_file.lastIndexOf(".")) + "_" + FilenameUtils.getExtension(src_file) );
//Actual Conversion
converter.convert( new File(src_file), new File( src_file.substring(0, src_file.lastIndexOf(".")) + "_"
+ FilenameUtils.getExtension(src_file) +"_Jod.pdf") );
System.out.println("Time Taken in conversion - "+ (System.currentTimeMillis() - start) + "ms");
} catch (Throwable e) {
e.printStackTrace();
}
}
}
And the relevant jars can be downloaded from : https://drive.google.com/file/d/0B4hS5IGxGOh9OE5Ca0RlbTdVclU/view?usp=sharing