How to make a footer stick to the 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.
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
).