如何在 Java 中将 xsl-fo 转换为 docx (Office Open XML)?

发布于 2024-10-06 00:44:14 字数 229 浏览 0 评论 0原文

我正在寻找 Java 中的开源或商业友好库,以将 xsl-fo 转换为 docx (Office Open XML) 格式。

我计划使用 xsl-fo 生成 pdf 文档(使用 Apache FOP),所以我想生成 Word 文档 (docx)使用相同的源 XML 可能是一个好主意。

更新:我忘了提及我正在使用 Java。

I'm looking for an open-source or commercial friendly library in Java to convert xsl-fo to docx (Office Open XML) format.

I'm planing to use xsl-fo to produce pdf documents (with Apache FOP), so I thought generating Word documents (docx) out of the same source XML could be a good idea.

UPDATE: I forgot to mention that I'm using Java.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我的痛♀有谁懂 2024-10-13 00:44:14

或者,您可以这样做:您的源 xml -> docx-> xsl-fo-> pdf。

或者更简单:source xml ->扁平 OPC XML -> xsl-fo-> pdf。

一旦您有了 docx(或 Flat OPC XML 文档),使用 docx4j 通过 FOP 将其转换为 PDF 就很容易了(既然您提到了 FOP,我假设 Java 适合您)。

这种方法的好处是您可以根据需要设置输出 docx 的样式,并“免费”获得 xsl fo。

Flat OPC XML 很方便,因为它是 docx 作为单个 XML 文件(即无需解压缩)。因此您可以通过 XSLT 轻松创建它。要查看它,请在 Word 2007 中创建一个文档,然后选择“另存为 .. xml”。

Alternatively, you could do: your source xml -> docx -> xsl-fo -> pdf.

or easier perhaps: source xml -> Flat OPC XML -> xsl-fo -> pdf.

Once you have a docx (or a Flat OPC XML document), transforming that to PDF via FOP is easy with docx4j (since you mention FOP, I'm assuming Java is ok for you).

The benefit of this approach is that you style your output docx as desired, and get the xsl fo "for free".

Flat OPC XML is convenient, because it is docx as a single XML file (ie no need to unzip). So you can create it easily via XSLT. To see it, create a document in Word 2007, and choose "save as .. xml".

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文