InputStream is = new FileInputStream( new File("D:\\javadomain.docx")); WordprocessingMLPackage wordMLPackage = WordprocessingMLPackage .load(is); List sections = wordMLPackage.getDocumentModel().getSections(); for (int i = 0; i < sections.size(); i++) {
wordMLPackage.setFontMapper(fontMapper); PdfSettings pdfSettings = new PdfSettings(); org.docx4j.convert.out.pdf.PdfConversion conversion = new org.docx4j.convert.out.pdf.viaXSLFO.Conversion( wordMLPackage);
OutputStream out = new FileOutputStream(new File( "D:\\javadomain.pdf")); conversion.output(out, pdfSettings); System.err.println("Time taken to Generate pdf " + (System.currentTimeMillis() - start) + "ms");