Legacy notice!

iText 5 is the previous major version of iText's leading PDF SDK. iText 5 has been EOL, and is no longer developed. Switch your project to iText 7, integrating the latest developments.
Check related iText 7 content!

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.