private static void docx2pdfFO() throws Exception { String regex = null; PhysicalFonts.setRegex(regex); String inputfilepath = System.getProperty("user.dir") + "/pdf/OneColumnAndTwoColumns.docx"; String outputfilepath = System.getProperty("user.dir") + "/pdf/OneColumnAndTwoColumns_FO.pdf"; WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage.load(new File(inputfilepath)); // Refresh the values of DOCPROPERTY fields FieldUpdater updater = new FieldUpdater(wordMLPackage); updater.update(true); VariablePrepare.prepare(wordMLPackage); // All methods write to an output stream OutputStream os = new java.io.FileOutputStream(outputfilepath); Mapper fontMapper = new IdentityPlusMapper(); wordMLPackage.setFontMapper(fontMapper); PhysicalFont font = PhysicalFonts.get("Arial Unicode MS"); FOSettings foSettings = Docx4J.createFOSettings(); foSettings.setFoDumpFile(new File(inputfilepath + ".fo")); foSettings.setWmlPackage(wordMLPackage); Docx4J.toFO(foSettings, os, Docx4J.FLAG_EXPORT_PREFER_XSL); }