Created
July 4, 2018 15:44
-
-
Save ulugbekrozimboyev/2a4daf46d1146b5910315eb81071c908 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class JODConverter { | |
private static volatile OfficeManager officeManager; | |
private static volatile OfficeDocumentConverter converter; | |
public static void startOfficeManager(){ | |
try { | |
officeManager = new DefaultOfficeManagerConfiguration() | |
.setOfficeHome(new File('libre office home path')) | |
.setPortNumbers(8100, 8101, 8102, 8103, 8104 ) | |
.setTaskExecutionTimeout(600000L) // for big files | |
.setTaskQueueTimeout(200000L) // wait if all port were busy | |
.buildOfficeManager(); | |
officeManager.start(); | |
// 2) Create JODConverter converter | |
converter = new OfficeDocumentConverter(officeManager); | |
} catch (Throwable e){ | |
e.printStackTrace(); | |
} | |
} | |
public static void convertPDF(File inputFile, File outputFile) throws Throwable { | |
converter.convert(inputFile, outputFile); | |
} | |
public static void stopOfficeManager(){ | |
officeManager.stop(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment