title: Add header to only the first PDF page using Itext in java
body: <p>I am using iText for generating PDF documents in my project and it is working fine. I am adding header and footer in the onEndPage method with writer.setPageEvent.</p>
  
  <pre><code>@Override
      public void onEndPage(PdfWriter writer, Document document) {
          try {
              addHeader(writer);
          } catch (IOException e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
          }
          addFooter(writer);
      }
  </code></pre>
  
  <p>My problem is I want to display the header only on the first page and not in subsequent pages. But the header is getting displayed on all the pages. </p>