title: How to add a table in absolute position at the beginning of the page using iTextSharp?
body: <p>I have a class named <strong>PdfHeaderFooter</strong> that extends <strong>PdfPageEventHelper</strong> class.</p>
  
  <p>In this class I have implemented the <strong>OnEndPage()</strong> method in this way. How you can see this method create the <strong>header</strong> and the <strong>footer</strong> of each pages of the document.</p>
  
  <p>Now I have to add the <strong>PdfPTable tabHead</strong> in absolute position at the beginning of the page.</p>
  
  <p>What can I have to do? I am going crazy trying to do it</p>
  
  <pre><code>    // write on end of each page
      public override void OnEndPage(PdfWriter writer, Document document)
      {
          base.OnEndPage(writer, document);
  
          // HEADER:
          PdfPTable tabHead = new PdfPTable(3);
          tabHead.SetWidths(new int[] { 165, 205, 125 });
  
  
          //tabHead.TotalWidth = 460F;
          tabHead.TotalWidth = document.Right - document.Left;        // TotalWidth = 495
          tabHead.WidthPercentage = 98;
  
  
          PdfPCell cell1 = new PdfPCell(iTextSharp.text.Image.GetInstance(folderImages + "logoEarlyWarning.png"), true) { Border = PdfPCell.BOTTOM_BORDER };
          tabHead.AddCell(cell1);
          //tabHead.AddCell(new PdfPCell(new Phrase("CELL 1:")) { Border = PdfPCell.BOTTOM_BORDER, Padding = 5, MinimumHeight = 50, PaddingTop = 15, });
  
          tabHead.AddCell(new PdfPCell(new Phrase("")) { Border = PdfPCell.BOTTOM_BORDER, Padding = 5, MinimumHeight = 50, PaddingTop = 15 });
  
          if (_sourceId == "NVD")
          {
              iTextSharp.text.Image logo = iTextSharp.text.Image.GetInstance(folderImages + "nvdLogo.png");
              logo.ScalePercent(48f);
              //PdfPCell cell3 = new PdfPCell(iTextSharp.text.Image.GetInstance(folderImages + "nvdLogo.png"), true) { Border = PdfPCell.BOTTOM_BORDER, PaddingBottom = 25 };
              PdfPCell cell3 = new PdfPCell(logo) { Border = PdfPCell.BOTTOM_BORDER, PaddingLeft = 50 };
              tabHead.AddCell(cell3);
          }
          else if (_sourceId == "DeepSight")
          {
              PdfPCell cell3 = new PdfPCell(iTextSharp.text.Image.GetInstance(folderImages + "DSLogo.jpg"), true) { Border = PdfPCell.BOTTOM_BORDER };
              tabHead.AddCell(cell3);
          }
          //tabHead.AddCell(new PdfPCell(new Phrase("CELL 3:")) { Border = PdfPCell.BOTTOM_BORDER, Padding = 5, MinimumHeight = 50, PaddingTop = 15 });
  
  
          tabHead.WriteSelectedRows(0, -1, document.Left, document.Top, writer.DirectContent);
  
          float headerHeight = tabHead.CalculateHeights();
  
  
          // FOOTER:
          int pageN = writer.PageNumber;      // numero della pagina corrente OK
          String text = "Page " + pageN + " of ";
          float len = bf.GetWidthPoint(text, 8);
  
          Rectangle pageSize = document.PageSize;
  
          cb.SetRGBColorFill(100, 100, 100);
  
          cb.BeginText();
          cb.SetFontAndSize(bf, 8);
          cb.SetTextMatrix(pageSize.GetLeft(40), pageSize.GetBottom(30));
          cb.ShowText(text);
          cb.EndText();
  
          cb.AddTemplate(template, pageSize.GetLeft(40) + len, pageSize.GetBottom(30));
  
          cb.BeginText();
          cb.SetFontAndSize(bf, 8);
          cb.ShowTextAligned(PdfContentByte.ALIGN_RIGHT,
              "Printed On " + PrintTime,
              pageSize.GetRight(40),
              pageSize.GetBottom(30), 0);
          cb.EndText();
  
      }
  </code></pre>
  
  <p>Tnx</p>