如何以编程方式在java中将doc,docx文件转换为pdf [英] how to convert doc,docx files to pdf in java programatically

查看:43
本文介绍了如何以编程方式在java中将doc,docx文件转换为pdf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以使用 docx4j 从 docx 文件生成 pdf.但是我需要将 doc 文件转换为 pdf,包括图像和表格.有没有办法在java中将doc转换为docx.或者(从 doc 到 pdf)?

I am able to generate pdf from docx file using docx4j.But i need to convert doc file to pdf including images and tables. Is there any way to convert doc to docx in java. or (doc to pdf)?

推荐答案

docx4j 包含 org.docx4j.convert.in.Doc,它使用 POI 来读取 .doc,但它是概念验证,而不是生产就绪代码.最后我检查了一下,POI 对二进制 .doc 的 HWPF 解析存在限制.

docx4j contains org.docx4j.convert.in.Doc, which uses POI to read the .doc, but it is a proof of concept, not production ready code. Last I checked, there were limits to POI's HWPF parsing of a binary .doc.

进一步 mqchen 的评论,您可以使用 LibreOffice 或 OpenOffice 将 doc 转换为 docx.但是如果您打算使用 LibreOffice 或 OpenOffice,您不妨使用它直接将 .doc 和 .docx 转换为 PDF.谷歌jodconverter".

Further to mqchen's comment, you can use LibreOffice or OpenOffice to convert doc to docx. But if you are going to use LibreOffice or OpenOffice, you may as well use it to convert both .doc and .docx directly to PDF. Google 'jodconverter'.

这篇关于如何以编程方式在java中将doc,docx文件转换为pdf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆