title: Adding new page in itextsharp will overlap with header
body: <p>I am using iTextSharp version 5.4.5.0.</p>
  
  <p>I have a problem while adding new page using document.NewPage() method.</p>
  
  <p>When I will use above method to add new page, the content of this new page will overlap with my header section. I have created my header table in <code>OnEndPage()</code> method of <code>PdfPageEventHelper</code> class.</p>
  
  <p>Here is the code for my header in <code>OnEndPage</code> event:</p>
  
  <pre><code>PdfPTable table = new PdfPTable(1);
  table.TotalWidth = document.PageSize.Width - document.LeftMargin - document.RightMargin;
  PdfPTable headerTable = new PdfPTable(1) { TotalWidth = document.PageSize.Width };
  
  PdfPCell cImage = new PdfPCell(ImageHeader, true);
  cImage.HorizontalAlignment = Element.ALIGN_RIGHT;
  cImage.Border = iTextSharp.text.Rectangle.NO_BORDER;
  cImage.FixedHeight = 45f;
  cImage.PaddingTop = 0f;
  
  headerTable.AddCell(cImage);
  
  PdfPCell cell = new PdfPCell(headerTable) { Border = Rectangle.NO_BORDER };
  table.AddCell(cell);
  
  table.WriteSelectedRows(0, -1, document.LeftMargin, document.Top, writer.DirectContent);   // Here the document.Top value is 45
  </code></pre>
  
  <p>And I have also assign margin top as 45 while creating document object as below:</p>
  
  <pre><code>MemoryStream workStream = new MemoryStream();
  Document document = new Document(); 
  
  PdfWriter writer = PdfWriter.GetInstance(document, workStream);
  document.SetMargins(30, 30, 45, 30);
  </code></pre>
  
  <p>Can anyone help me to not overlap document content with header table while adding new page ?</p>
  
  <p>Thanks.</p>