这个主要的问题是,那些
PdfOptions和
PdfConverter是不是的一部分
apache poi项目。它们是由开发的
opensagres,
第一个版本的命名错误
org.apache.poi.xwpf.converter.pdf.PdfOptions和
org.apache.poi.xwpf.converter.pdf.PdfConverter。这些老班都没有更新,因为2014年和需要的版本3.9中apache poi使用。
请使用更多 最新版本的
fr.opensagres.poi.xwpf.converter.pdf,该版本可以使用最新的稳定版本进行工作apache poi 3.17。
然后做
import java.io.InputStream;import java.io.OutputStream;import java.io.FileInputStream;import java.io.FileOutputStream;import java.io.File;//needed jars: fr.opensagres.poi.xwpf.converter.core-2.0.1.jar, // fr.opensagres.poi.xwpf.converter.pdf-2.0.1.jar,// fr.opensagres.xdocreport.itext.extension-2.0.1.jar,// itext-2.1.7.jar import fr.opensagres.poi.xwpf.converter.pdf.PdfOptions;import fr.opensagres.poi.xwpf.converter.pdf.PdfConverter;//needed jars: apache poi and it's dependenciesimport org.apache.poi.xwpf.usermodel.XWPFdocument;public class DOCXToPDFConverterSampleMin { public static void main(String[] args) throws Exception { String docPath = "./Worddocument.docx"; String pdfPath = "./Worddocument.pdf"; InputStream in = new FileInputStream(new File(docPath)); XWPFdocument document = new XWPFdocument(in); PdfOptions options = PdfOptions.create(); OutputStream out = new FileOutputStream(new File(pdfPath)); PdfConverter.getInstance().convert(document, out, options); document.close(); out.close(); }}2018年10月:此代码可使用
apache poi 3.17。使用它不能工作,
apache poi 4.0.0由于
changings apache poi这不采取
帐户
fr.opensagres.poi.xwpf.converter直到现在。
2019年2月:对我的作品现在使用的最新apache poi版本4.0.1和最新版本2.0.2的
fr.opensagres.poi.xwpf.converter.core和配偶。



