四川省城乡建设厅门户网站WordPress开启邮件服务
四川省城乡建设厅门户网站,WordPress开启邮件服务,2017网站制作报价单,自己做网站 怎么解决安全问题之前记录了按照模板生成 DOCX 文件、并转换为 PDF 文件的方法 https://blog.csdn.net/qq_40096897/article/details/131979177?spm1001.2014.3001.5501
但是使用效果并不是很理想#xff0c;转换完的 PDF 格式和原本的文档格式不匹配。所以在此重新找了一个文件转 PDF 的方法…之前记录了按照模板生成 DOCX 文件、并转换为 PDF 文件的方法 https://blog.csdn.net/qq_40096897/article/details/131979177?spm1001.2014.3001.5501
但是使用效果并不是很理想转换完的 PDF 格式和原本的文档格式不匹配。所以在此重新找了一个文件转 PDF 的方法。
dependencygroupIdcom.luhuiguo/groupIdartifactIdaspose-pdf/artifactIdversion23.1/version
/dependency
dependencygroupIdcom.luhuiguo/groupIdartifactIdaspose-words/artifactIdversion23.1/version
/dependency可以保存为输出流
InputStream inputStream new FileInputStream(F:\\test.docx);
try (ByteArrayOutputStream outPDF new ByteArrayOutputStream()) {//转PDFcom.aspose.words.Document doc new com.aspose.words.Document(inputStream);doc.save(outPDF, com.aspose.words.SaveFormat.PDF);
} catch (IOException e) {e.printStackTrace();
}
inputStream.close();也可以直接保存为指定文件
InputStream inputStream new FileInputStream(F:\\test.docx);
com.aspose.words.Document doc new com.aspose.words.Document(inputStream);
doc.save(F:\\test.pdf, com.aspose.words.SaveFormat.PDF);
inputStream.close();效果如下 这是DOCX模板模板格式如下 这是按照模板生成文档后再转为PDF的效果
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/pingmian/87927.shtml
如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!