title: iTextSharp PageNumber but not on first and last pages
body: <p>I am trying to show the page number of my PDF pages, but I don`t want to show it on first and last pages, because they are covers.</p>
  
  <p>I use this code:</p>
  
  <pre><code>public class PDFPage : iTextSharp.text.pdf.PdfPageEventHelper
  {
      //I create a font object to use within my footer
      protected iTextSharp.text.Font footer
      {
          get
          {
              // create a basecolor to use for the footer font, if needed.
              iTextSharp.text.Color grey = new iTextSharp.text.Color(40, 40, 40);
              Font font = FontFactory.GetFont("Arial", 16, iTextSharp.text.Font.BOLD, grey);
              return font;
          }
      }
  
      //override the OnPageEnd event handler to add our footer
      public override void OnEndPage(PdfWriter writer, Document doc)
      {
          if (doc.PageNumber &gt; 1)
          {
              //I use a PdfPtable with 2 columns to position my footer where I want it
              PdfPTable footerTbl = new PdfPTable(2);
  
              //set the width of the table to be the same as the document
              footerTbl.TotalWidth = doc.PageSize.Width;
  
              //Center the table on the page
              footerTbl.HorizontalAlignment = Element.ALIGN_CENTER;
  
              //Create a paragraph that contains the footer text
              Paragraph para = new Paragraph(" ", footer);
  
              //add a carriage return
              para.Add(Environment.NewLine);
              para.Add(" ");
  
              //create a cell instance to hold the text
              PdfPCell cell = new PdfPCell(para);
  
              //set cell border to 0
              cell.Border = 0;
  
              //add some padding to bring away from the edge
              cell.PaddingLeft = 10;
  
              //add cell to table
              footerTbl.AddCell(cell);
  
              //create new instance of Paragraph for 2nd cell text
              para = new Paragraph(" " + doc.PageNumber, footer);
  
              //create new instance of cell to hold the text
              cell = new PdfPCell(para);
  
              //align the text to the right of the cell
              cell.HorizontalAlignment = Element.ALIGN_LEFT;
              //set border to 0
              cell.Border = 0;
  
              // add some padding to take away from the edge of the page
              cell.PaddingRight = 10;
  
              //add the cell to the table
              footerTbl.AddCell(cell);
  
              //write the rows out to the PDF output stream.
              footerTbl.WriteSelectedRows(0, -1, 0, (doc.BottomMargin + 25), writer.DirectContent);
          }
      }
  
  }
  </code></pre>
  
  <p>Thank you!</p>