title: How to add a "Page X of Y" footer in iText 7
body: <p>I'm trying to figure out how to add a "Page X of Y" footer to each page in a PDF document, which I'm generating using <strong>iText 7</strong>.</p>
  
  <p>Using an IEventHandler to generate the "Page X" part seems fairly straightforward - it's the "of Y" bit that I'm struggling with. I want to avoid generating the whole document twice in order to find out how many pages it has, as this would be a significant performance hit!</p>
  
  <p>I've found a solution for this in <strong>iText 5</strong> here: <a href="https://stackoverflow.com/questions/11205777/pdf-page-numbering-in-java-itext">PDF Page Numbering in Java &amp; iText</a>, but <strong>iText 7</strong> is a complete rewrite of iText with a totally different interface and so far I've been unable to find any similar <strong>iText 7</strong> examples.</p>