Skip to main content
Skip table of contents

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.

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).

Click this link if you want to see how to answer this question in iText 7.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.