How to make a footer stick to bottom of every pdf page?

I'm using ItextSharp to create a PDF with content from my database. This content is visualized as a table. For this table, I define a footer that sticks to the bottom of every page except for the last page because there might not be enough content to "push" the footer down. How can I make sure that my footer stays at the bottom of every page no matter what?

Posted on StackOverflow on Feb 17, 2015 by Carsten Løvbo Andersen

Please take a look at the source code of PdfPTable, more specifically at the SetExtendLastRow() method:

/**
 * When set the last row on every page will be extended to fill
 * all the remaining space to the bottom boundary; except maybe the
 * final row.
 *
 * @param extendLastRows true to extend the last row on each page;
 *     false otherwise
 * @param extendFinalRow false if you don't want to extend
 *     the final row of the complete table
 * @since iText 5.0.0
 */
public void SetExtendLastRow(bool extendLastRows, bool extendFinalRow) {
    extendLastRow[0] = extendLastRows;
    extendLastRow[1] = extendFinalRow;
}

If you want the last row to extend to the bottom of the last page, you need to set extendFinalRow to true (the default for extendLastRows and extendFinalRow is false).



Ready to use iText?

Try our iText 7 Library and add-ons FREE for 30 days. Test your proof of concept, and see if our solution is right for you.

Get my FREE trial
Contact

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