我試圖使用JOD Converter將文檔(.docx/.xlsx/.pptx)轉換爲PDF。我在Centos 7上使用OpenOffice 4.1.2。我的問題是,當我轉換文件時,我的CPU佔用率達到了100%,這影響了整個機器的性能。我已經嘗試了命令行選項中的所有可能的選項,但不幸的是,還沒有能夠緩解這個問題。我在很多論壇上搜索過,發現很多其他人也面臨同樣的問題,但是,這裏沒有解決方案。通過我的閱讀,我意識到這可能是因爲OpenOffice中的內存泄漏問題。有人可以幫助我解決或至少減輕這個問題嗎?使用OpenOffice4時CPU利用率100%
下面是我用產卵OpenOffice的實例的命令。
/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
的代碼我使用的文件轉換爲: 包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();
}
}
}
和相關的罐子可以從以下網址下載: https://drive.google.com/file/d/0B4hS5IGxGOh9OE5Ca0RlbTdVclU/view?usp=sharing
避免約旦第納爾轉換器和使用Ghostscript打印文檔 – deblocker
@deblocker問題是與OpenOffice/LibreOffice,而不是JOD。僅供參考,我已經嘗試過Ghostscript,它沒有幫助。它進一步將轉換分爲兩部分:Doc - > PostScript - > PDF。 它使轉換時間增加了很多,這是我們真正想要保持的低位 – Geek
我過去做過大量的pdf大量打印,儘管不是您的OO版本,GS一直是我的最佳選擇。如果這對你沒有幫助,我很害怕。祝你好運! – deblocker