title: ITextSharp - include footer on every page but the first and the last
body: <p>Currently building a PDF with ITextSharp in C#. The PDF consists of three "parts", a cover page, a table that can span multiple pages, and a final page. The pages that have the table need to include a header on the first page, and a footer on all pages with it, but the cover page and final page do not. </p>
  
  <p>I build the pages using XMLWorker, but that's not really important. My code for building the pages is as follows:</p>
  
  <pre><code>    var htmlContext = new HtmlPipelineContext(null);
      htmlContext.SetTagFactory(iTextSharp.tool.xml.html.Tags.GetHtmlTagProcessorFactory());
      var cssResolver = XMLWorkerHelper.GetInstance().GetDefaultCssResolver(false);
      /* cssResolver.AddCssFile(@"style.css", true); */
      cssResolver.AddCssFile(@"style.css", true);
      var pipeline = new CssResolverPipeline(cssResolver, new HtmlPipeline(htmlContext, new PdfWriterPipeline(document, writer)));
      XMLWorker worker = new XMLWorker(pipeline, true);
      XMLParser p = new XMLParser(worker);
  
      /* write out cover page */
      p.Parse(coverpage);
  
      /* write out table */
      document.NewPage();
      writer.PageEvent = new PDFFooter();
      p.Parse(header); 
      p.Parse(ContentTable); 
  
      /* write out end page */
      document.NewPage();
      p.Parse(endPage);
  </code></pre>
  
  <p>The trouble I'm having is determining a way to keep the footer from appearing on the end page. I'm overriding OnEndPage to make the footer. Is there a way to detect the last page of the document (without knowing exactly what number page that'll be), and tell it not to use the override so that no footer is printed out?</p>