使用 Java 将 Word 文档隐藏为 XSL-FO
我正在尝试使用java将word文档转换为pdf。 “word to XSL-FO to pdf”是我正在寻找的方法。
在这种“word to XSL-FO”方法中,是否有可用的开源 API?或者您能指导我实施它的步骤吗?
I am trying to covert a word document to pdf using java. 'word to XSL-FO to pdf' is the approach i am looking at.
In this approach to do 'word to XSL-FO', is there any open source api available? or can you please guide me with steps for implementing it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您要转换哪个版本的 Word 文档?
RenderX 具有公开的 WordML2FO 样式表,可以转换 Microsoft 的 WordprocessingML将文档转换为 XSL FO (XSLFO)。
What version of Word document are you converting?
RenderX has WordML2FO stylesheets publicly available that can convert Microsoft's WordprocessingML documents to XSL FO (XSLFO).
我完全认为仅使用样式表不是正确的方法,因为您会错过太多东西(例如解析样式、用于 docx/word2003 文档内图形的 DrawingML/VML 等)。
尝试这个代码示例并从那里开始。另请注意,如果您使用 Microsoft 的 API 生成 Word 2003/2007,则除非您进行所有必需的函数调用,否则它的结构可能不会始终正确。
I totally think that using just a stylesheet is not the way to go because there are too many things you will miss (like resolving styles, drawingml/vml used for the graphics inside a docx/word2003 document, etc).
Try this code sample and move from there. Also to note is that if you generate your Word 2003/2007 using Microsoft's API, the structure of it may not be correct all the time unless you make all the required function calls.
docx4j(开源,Apache 许可证)可以为您做到这一点。
有关更多详细信息,请参阅 docx4j 入门指南。
docx4j (open source, Apache license) can do this for you.
See the docx4j Getting Started guide for further details.
您还可以尝试 Docmosis 或 JODConverter 只要您可以在某处安装 OpenOffice 即可进行转换。它们可以在许多平台上运行并且可以由 Java 控制。
You could also try Docmosis or JODConverter to do the conversion as long as you can install OpenOffice somewhere. They work on many platforms and can be Java controlled.