Java 的 PDF 生成库 [英] PDF Generation Library for Java

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

问题描述

我知道以前有人问过这个问题,但我仍然不确定要为我当前的项目使用哪个 PDF 生成框架.

I know this has been asked before, but I'm still undecided on which PDF generation framework to use for my current project.

我的要求

  • 即时生成 PDF 文档(主要是订单、发票)
  • 基于Java
  • 易于布局
  • 应该是开源的
  • 易于更改布局

似乎很多人都在使用 iText,但我对关注点分离有一些担忧(除了更改的许可证):在 HTML 上下文中有很好的 MVC 支持,我通常坚持使用Spring MVC 和 FreeMarker 来分离逻辑和布局.我有点担心使用 iText 你最终会大量混合代码和布局.

A lot of people seem to use iText, but I have some concerns (apart from the changed licence) regarding separation of concerns: In an HTML context there's good MVC support, where I usually stick to Spring MVC and FreeMarker to separate logic and layout. I'm a little bit worried that with iText you end up mixing code and layout a lot.

我知道,Apache FOP 在这里可能是一个解决方案,但我再次发现 XSLT 使用起来很乏味,而且我读到 FOP 在处理大量文档时可能会很慢?

I am aware, that Apache FOP could be a solution here, but then again I find XSLT tedious to work with and I read that FOP can be slow when it comes to huge throuput of many documents?

我也考虑过 JasperReports,但根据我的理解,这更适合包含表格数据集的报告,而不是单个文档,例如需要大量布局格式的发票?

I also considered JasperReports, but from my understanding this is more suited for reports containing tabular datasets rather than single documents such as invoices which require a lot of layout formatting?

对此有什么想法吗?

推荐答案

试试 JasperReports.使用 iReport 创建 .jrxml 文件.JapserReports 可以处理复杂的布局.对于基于不同查询的报告的那些部分,请查看使用嵌入到主报告中的子报告.

Give JasperReports a try. Use iReport to create the .jrxml files. JapserReports can handle complex layouts. For those parts of the report based on different queries have a look at using subreports embedded into the main report.

就像@Adrian Smith 的解决方案一样,这种方法会将报表布局编辑与数据来源分开.

Just like @Adrian Smith's solution this approach will separate the report layout editing from the data sourcing.

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

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