use of org.docx4j.openpackaging.packages.WordprocessingMLPackage in project docx4j-template by vindell.
the class Docx4jUtils method docxToPdf.
/**
* docx文档转换为PDF
*
* @param docx
* docx文档
* @param pdfPath
* PDF文档存储路径
* @throws Exception
* 可能为Docx4JException, FileNotFoundException, IOException等
*/
public static void docxToPdf(String docxPath, String pdfPath) throws Exception {
OutputStream output = null;
try {
output = new FileOutputStream(pdfPath);
WordprocessingMLPackage wmlPackage = WordprocessingMLPackage.load(new File(docxPath));
WMLPACKAGE_BUILDER.configChineseFonts(wmlPackage).configSimSunFont(wmlPackage);
WMLPACKAGE_WRITER.writeToPDF(wmlPackage, output);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
IOUtils.closeQuietly(output);
}
}
use of org.docx4j.openpackaging.packages.WordprocessingMLPackage in project docx4j-template by vindell.
the class WordprocessingMLBeetlTemplate_Test method test.
@Test
public void test() throws Exception {
variables.put("title", "变量替换测试");
variables.put("content", "测试效果不错");
WordprocessingMLPackage wordMLPackage = beetlTemplate.process("/tpl/beetl.tpl", variables);
File outputDocx = new java.io.File("src/test/resources/output/beetlTemplate_output.docx");
wordMLPackage.save(outputDocx);
}
use of org.docx4j.openpackaging.packages.WordprocessingMLPackage in project docx4j-template by vindell.
the class WordprocessingMLRythmTemplate_Test method test.
@Test
public void test() throws Exception {
variables.put("title", "变量替换测试");
variables.put("content", "测试效果不错");
WordprocessingMLPackage wordMLPackage = rythmTemplate.process("/tpl/rythm.tpl", variables);
File outputDocx = new java.io.File("src/test/resources/output/rythmTemplate_output.docx");
wordMLPackage.save(outputDocx);
}
use of org.docx4j.openpackaging.packages.WordprocessingMLPackage in project docx4j-template by vindell.
the class WordprocessingMLThymeleafTemplate_Test method test.
@Test
public void test() throws Exception {
variables.put("title", "变量替换测试");
variables.put("content", "测试效果不错");
WordprocessingMLPackage wordMLPackage = thymeleafTemplate.process("/tpl/thymeleaf.tpl", variables);
File outputDocx = new java.io.File("src/test/resources/output/thymeleafTemplate_output.docx");
wordMLPackage.save(outputDocx);
}
use of org.docx4j.openpackaging.packages.WordprocessingMLPackage in project docx4j-template by vindell.
the class WordprocessingMLJetbrickTemplate_Test method test.
@Test
public void test() throws Exception {
variables.put("title", "变量替换测试");
variables.put("content", "测试效果不错");
WordprocessingMLPackage wordMLPackage = jetbrickTemplate.process("/tpl/jetbrick.jetx", variables);
File outputDocx = new java.io.File("src/test/resources/output/jetbrickTemplate_output.docx");
wordMLPackage.save(outputDocx);
}
Aggregations