如何在 Java 中将 xsl-fo 转换为 docx(Office Open XML)? [英] How to convert xsl-fo to docx (Office Open XML) in Java?

查看:24
本文介绍了如何在 Java 中将 xsl-fo 转换为 docx(Office Open XML)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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.

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

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

推荐答案

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

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

或者更简单:source xml -> Flat OPC XML -> xsl-fo -> pdf.

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

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

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).

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

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

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

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".

这篇关于如何在 Java 中将 xsl-fo 转换为 docx(Office Open XML)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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