/** * docx文档转换为PDF * * @param wordMLPackage * @param pdfPath PDF文档存储路径 * @throws Exception */ public static void convertDocxToPDF(WordprocessingMLPackage wordMLPackage, String pdfPath) throws Exception { //HashSet<String> features = new HashSet<>(); //features.add(PP_PDF_APACHEFOP_DISABLE_PAGEBREAK_LIST_ITEM); //WordprocessingMLPackage process = Preprocess.process(wordMLPackage, features); FileOutputStream fileOutputStream = new FileOutputStream(pdfPath); Docx4J.toPDF(wordMLPackage, fileOutputStream); fileOutputStream.flush(); fileOutputStream.close(); /*FOSettings foSettings = Docx4J.createFOSettings(); foSettings.setWmlPackage(wordMLPackage); Docx4J.toFO(foSettings, fileOutputStream, Docx4J.FLAG_EXPORT_PREFER_XSL);*/ }
@Override public void convert() throws Exception{ loading(); InputStream iStream = inStream; WordprocessingMLPackage wordMLPackage = getMLPackage(iStream); processing(); Docx4J.toPDF(wordMLPackage, outStream); finished(); }
outputStream.flush(); } else { Docx4J.toPDF(wordprocessingMLPackage, outputStream); outputStream.flush();
outputStream.flush(); } else { Docx4J.toPDF(wordprocessingMLPackage, outputStream); outputStream.flush();