从XML或HTML生成PDF文件 [英] PDF file generation from XML or HTML

查看:248
本文介绍了从XML或HTML生成PDF文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有任何API /解决方案可以从XML文件数据和定义中生成PDF报告。
例如,XML定义/数据可以是:

 < pdf> 
< paragraph font =Arial>报告标题< / paragraph>
< / pdf>

将HTML转换为PDF也是一个很好的解决方案。



目前我们使用iText API编写Java代码。我希望将代码外部化,以便非技术人员可以编辑和修改。 =http://xmlgraphics.apache.org/fop/ =noreferrer> Apache FOP 。使用XSLT样式表将XML(或XHTML)转换为XSL-FO。然后使用FOP读取XSL-FO文档并将其格式化为PDF文档(请参阅 Hello World with FOP )。


Are there any API/solution to generate PDF report from XML file data and definition. For example the XML definition/data could be:

<pdf>
    <paragraph font="Arial">Title of report</paragraph>
</pdf>

Converting HTML to PDF will be also a good solution I feel.

Currently we write Java code using iText API. I want to externalize the code so that non-technical person can edit and make changes.

解决方案

Have a look at Apache FOP. Use an XSLT stylesheet to convert the XML (or XHTML) into XSL-FO. Then use FOP to read the XSL-FO document and format it to a PDF document (see Hello World with FOP).

这篇关于从XML或HTML生成PDF文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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