title: Page X of Y issue
body: <p>I tried 3 different ways of displaying Page numbers,  <code>OnCloseDocument</code> content is not displaying in the page, none of them worked.</p>
  
  <p>My Intention is displaying <strong>Page numbers</strong> like this</p>
  
  <p><strong>1 of 10<br/>
    2 0f 10<br/>
  ..............<br/>
  ............<br/>
   10 of 10 
   on each page</strong></p>
  
  <p>I know how to display</p>
  
  <p><strong>1 <br/>
  2 <br/>
  3<br/>
  4<br/>
  ....<br/>
  10</strong></p>
  
  <p>but <strong>don`t know how to display total page number</strong></p>
  
  <p>I`m using   <strong>OnCloseDocument</strong>  to display  No.of pages count,but the <strong>content in it is
  not displaying.</strong></p>
  
  <pre><code>public class MyPdfPageEventHelpPageNo : iTextSharp.text.pdf.PdfPageEventHelper
  {
      protected PdfTemplate total;
      protected BaseFont helv;
      private bool settingFont = false;
  
      public override void OnOpenDocument(PdfWriter writer, Document document)
      {
          template= writer.DirectContent.CreateTemplate(100, 100);       
  
          bf = BaseFont.CreateFont(BaseFont.HELVETICA, BaseFont.WINANSI, BaseFont.NOT_EMBEDDED);
      }
      public override void OnCloseDocument(PdfWriter writer, Document document)
      {
      //See below
      }
  </code></pre>
  
  <p><strong>1ST WAY:</strong></p>
  
  <pre><code>    public override void OnCloseDocument(PdfWriter writer, Document document)     
      {
          //I create a table with one column like below.
          PdfPTable pageNumber2 = new PdfPTable(1);
          pageNumber2.TotalWidth = 50;
          pageNumber2.HorizontalAlignment = Element.ALIGN_RIGHT;
  
          pageNumber2.AddCell(BuildTable2RightCells("Page " + writer.PageNumber));
          pageNumber.AddCell(BuildTable2LeftCells(writer.PageCount));
          pageNumber2.WriteSelectedRows(0, -1, 500, 
          (document.PageSize.GetBottom(140)), cb);
      }    
  </code></pre>
  
  <p><strong>2ND WAY:</strong></p>
  
  <pre><code>    public override void OnCloseDocument(PdfWriter writer, Document document)     
      {
          ColumnText.ShowTextAligned(template,Element.ALIGN_CENTER,new
          Phrase(writer.PageNumber.ToString()), 500, 140, 0);
      }
  </code></pre>
  
  <p><strong>3RD WAY:</strong></p>
  
  <pre><code>    public override void OnCloseDocument(PdfWriter writer, Document document)     
      {
          template.BeginText();
          template.SetFontAndSize(bf, 8);
          template.SetTextMatrix(500, 140);
          template.ShowText(Convert.ToString((writer.PageNumber - 1)));
          template.EndText();
      }
  </code></pre>
  
  <p>Am I doing anything wrong?</p>