docx4j的“入门”文档包含将docx编写为pdf的示例代码:
// Set up converter
org.docx4j.convert.out.pdf.PdfConversion c =
new org.docx4j.convert.out.pdf.viaXSLFO.Conversion(wordMLPackage);
但是,从docx4j 3.0开始,整个PdfConversion工具似乎已被弃用,但没有通知现在如何执行转换。那么使用docx4j 3.0将docx转换为pdf的非弃用方法是什么。
答案 0 :(得分:9)
您就是这样做的:
Docx4J.toPDF(wordMLPackage, new FileOutputStream("path/to/your-pdf-file.pdf"));
答案 1 :(得分:5)
docx4j 3.0有一个可用于转换为PDF的外观。
有一个在
使用它的例子答案 2 :(得分:1)
足够说...来自示例源代码:
* From v3.3.0, PDF output is by default via Plutext's commercial PDF Converter.
*
* By default, the evaluation instance at:
*
* http://converter-eval.plutext.com:80/v1/00000000-0000-0000-0000-000000000000/convert
*
* is used. To specify your own instance, please set docx4j.properties property:
*
* com.plutext.converter.URL=http://your.host:80/v1/00000000-0000-0000-0000-000000000000/convert
*
* If you don't want to use Plutext's PDF Converter, you can still use XSL FO and Apache FOP;
* just put docx4j-export-fo and its depedencies on your classpath and use Docx4J.toFO
* as per the example below.
那么,如果你不得不重新使用XSL-FO / FOP,那么使用Docx4J是什么意思......?