使用 XSL FO 和 Python 从 XML 创建 PDF [英] Creating a PDF from XML using XSL FO w/ Python

查看:28
本文介绍了使用 XSL FO 和 Python 从 XML 创建 PDF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能指出我希望库或代码示例的正确方向,任何有关如何在 Python 中使用 XSL-FO 获取 XML 和创建 PDF 的资源吗?如果必须使用 XML 渲染器,那么推荐使用哪种 XML 渲染器?

Could someone point me in the right direction of hopefully a library or code examples, any resources on how to take XML and create a PDF using XSL-FO in Python? If I should have to use an XML renderer, then which XML renderer is recommended?

推荐答案

如果你想用 Python 以编程方式运行 XSLT,你需要 lxml.

If you want to run XSLT programmatically with Python, you want lxml.

然而,如果您只需要从定义的 XSL/XML 对创建一个 .fo 文件,您不妨使用 xsltproc,它可以在任何 Unix-y 系统上的命令上使用行,包括 OS X.

However, if you just need to create a .fo file from a defined XSL/XML pair, you might as well just use xsltproc, which is available on any Unix-y system on the command line, including OS X.

获得 .fo 文件后,使用 Fop 将其转换为 PDF.

Once you have the .fo file, use Fop to transform that to PDF.

这篇关于使用 XSL FO 和 Python 从 XML 创建 PDF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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