使用java,Itext生成pdf文件

时间:2010-08-05 12:30:29

标签: java pdf pdf-generation itext

我的要求是生成pdf,如果数据更多而不是在新页面中创建整个数据,则应在页面之间分割从数据库中检索的数据。

例如,有时当一个表必须在另一个页面上拆分时,拆分行的某些单元格应出现在前一页面上,而其他单元格出现在下一页面上。

请提供帮助。

4 个答案:

答案 0 :(得分:0)

您考虑过iReport吗?

答案 1 :(得分:0)

也许您应该考虑查看Jasper Reports

答案 2 :(得分:0)

PdfPTable跨页面拆分。构建其中一个很容易。

缺点是,根据您的特定需求设置表格可能会很麻烦。您可能需要为它编写一些抽象。

获得文档后,添加表格/单元格非常简单:

Document document = // some document
PdfPTable table = new PdfPTable(columns);
table.addCell(new PdfPCell("data goes here));

答案 3 :(得分:0)

如果您在iText中使用手动Java编码,我认为您需要:

PdfPTable table; // your table

table.setKeepTogether(false); // allows table to split table
table.setHeaderRows(1);       // rows of header
table.setFooterRows(2);       // rows of footer

有关表footers and headers中的check iText official website的更多信息和示例。