I'm using Docx4J to convert docx files to pdf. But the conversion seems to take too long, approximately 20 secs for one document.
All of my docx files are just one page documents and the resulting PDF files are ~ 100 KB. I tried to do multi-threading to achileve higher conversion rate but it seems to make it worse as the time taken jumps to 40 secs. My save to PDF code looks like below. Please suggest me some way to decrease the conversion time.
- Code: Select all
Mapper fontMapper;
File dir = new File(System.getProperty("user.dir") + "/fonts");
File[] directoryListing = dir.listFiles();
if (directoryListing != null) {
for (File child : directoryListing) {
PhysicalFonts.addPhysicalFont(child.toURL());
}
}
fontMapper = new IdentityPlusMapper();
wordMLPackage.setFontMapper(fontMapper);
FOSettings foSettings = Docx4J.createFOSettings();
foSettings.setWmlPackage(wordMLPackage);
String outputfilepath;
outputfilepath = System.getProperty("user.dir") + "/Output.pdf";
OutputStream os = new java.io.FileOutputStream(outputfilepath);
Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL);
My environment is Unix with Java 1.6