How to add a table to the bottom of the last page?

I have created table in a PDF document using iText. This works fine, but I don't want to add the table at the current pointer in the page, I want to add the table at the bottom.

24th October 2015


PdfPTable datatablebottom = new PdfPTable(8);
PdfPCell cell = new PdfPCell();
// add cells here
Posted on StackOverflow on Mar 9, 2014 by user3434594

You need to define the absolute width of your table:

    - document.left(document.leftMargin()));

Then you need to replace the line:


with this one:

datatable.writeSelectedRows(0, -1,
    datatable.getTotalHeight() + document.bottom(document.bottomMargin()),

The writeSelectedRows() method draws the table at an absolute position. We calculate that position by asking the document for its left margin (the x value) and by adding the height of the table to the bottom margin of the document (the Y coordinate). We draw all rows (0 to -1).


Still have questions? 

We're happy to answer your questions. Reach out to us and we'll get back to you shortly.

Contact us
Stay updated

Join 11,000+ subscribers and become an iText PDF expert by staying up to date with our new products, updates, tips, technical solutions and happenings.

Subscribe Now