Itextsharp make footer stick at bottom of every pdf page


Hello and thanks for reading this post.

I'm using ItextSharp to create a pdf with content from my database but thats not the important part.

My footer stick the bottom of every page except the last page because there might not be enought content to "push" it down.

Document ResultPDF = new Document(iTextSharp.text.PageSize.A4, 25, 10, 20, 30); PdfWriter Write = PdfWriter.GetInstance(ResultPDF, new FileStream(Server.MapPath("~") + "/PDF/" + fileName, FileMode.Create)); ResultPDF.Open(); PdfPTable Headtable = new PdfPTable(7); Headtable.TotalWidth = 525f; Headtable.LockedWidth = true; Headtable.HeaderRows = 5; Headtable.FooterRows = 2; Headtable.KeepTogether = true; ..... PdfPCell Footer = new PdfPCell(new Phrase(" ")) { Colspan = 7, UseVariableBorders = true, BorderColorTop = BaseColor.BLACK, BorderColorLeft = BaseColor.WHITE, BorderColorBottom = BaseColor.WHITE, BorderColorRight = BaseColor.WHITE }; PdfPCell Footer2 = new PdfPCell(new Phrase(Session["Surveyname"].ToString() + " - " + DateTime.Now.Date.ToString("dd-MM-yyyy") + " - " + email, smallText)) { Colspan = 6 }; PdfPCell Footer3 = new PdfPCell(new Phrase("", smallText)) { Colspan = 1, HorizontalAlignment = 1 }; Headtable.AddCell(Footer); Headtable.AddCell(Footer2); Headtable.AddCell(Footer3);

How can I make sure that my footer stay at the bottom of every page no matter what?

Thanks for your time.


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


  • iTextSharp Display only certain DataGridView columns
  • Adding new page in itextsharp will overlap with header
  • How to apply double line bottom border to a cell in iText
  • NoNewLineParagraph cannot be cast to Element
  • How do I add a footer in a PDF using iTextSharp VB.net?
  • Sent file has some corrupted data TCP sockets .. how to fix it?
  • How to deal with rapid consecutive file creation in a folder watched by a FileSystemWatcher?
  • ItextPdf Width Does Not Expand for Landscape Page
  • gzipstream.copyto alternate and easy way in .net 3.5
  • Clear data in column
  • Adobe Air FileStream Error #3013: File or directory is in use
  • FileReference vs File?
  • Read/decrypt encrypted XML file and then process internally
  • Attempting to use OOPFactory to parse 271 benefits using EligibilityBenefitDocument
  • Get rid of root element when serializing array
  • C# Append PDF file to MemoryStream - Cannot access a closed Stream
  • SendGrid - Image not showing up in HTML email
  • How to cancel and delete the uploading file in asp.net mvc 3?
  • How to add paragraph wise texts separated by vertical line into itextsharp created PDF
  • Cannot open include file: 'cpprest/http_client.h'
  • How to avoid OutOfMemoryException while loading large chunks of data from a database?
  • how do disable disk cache in c# invoke win32 CreateFile api with FILE_FLAG_NO_BUFFERING
  • Trying to delete files older than X number of days on insert in .NET MVC
  • Uploading file with WCF streaming, tiny reads from stream
  • Get entry assembly from ASP.NET application [duplicate]
  • Error: Type parameter 'T' cannot be inferred
  • how to set to NULL all the filestream varbinary(max) fields?
  • Bad request using file_get_contents for PUT request in PHP
  • Volusion's generic SQL folder, functionality
  • How to redirect a user to a different server and include HTTP basic authentication credentials?
  • Can I make an Android app that runs a web view in Chrome 39?
  • Adding custom controls to a full screen movie
  • Comma separated Values
  • Error creating VM instance in Google Compute Engine
  • Hits per day in Google Big Query
  • How do you join a server to an Active Directory (domain)?
  • coudnt use logback because of log4j
  • how does django model after text[] in postgresql [duplicate]
  • LevelDB C iterator
  • Linking SubReports Without LinkChild/LinkMaster