开发者

Generating pdf file using java, Itext

My requirement is to generate pdf where data retrieved from the database should be splitted between pages if data is more rather than creating e开发者_StackOverflowntire data in new page.

For instance sometimes when a table has to be splitted on another page, some cells of the splitted row should appear on the preceding page while the others appear on the next one.

PLease help on this.


Have you considered iReport?


Maybe you should consider looking at Jasper Reports


PdfPTable splits itself across pages. It's fairly easy to construct one of those.

The downside is that it can be a pain to style the table to your specific needs. You may need to write some abstractions for it.

Once you have your document, adding tables/cells is as easy as:

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


If you're using manual iText coding in Java I think you will need:

PdfPTable table; // your table

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

For further info and examples about footers and headers in tables check iText official website.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜