栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

Java中的Docx至Pdf转换器

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

Java中的Docx至Pdf转换器

这个主要的问题是,那些

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和配偶。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/486736.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号