title: Java iText: No EOF marker after adding watermark
body: <p>I need to add a watermark to a existing pdf file provided as byte array. I used <a href="http://developers.itextpdf.com/examples/stamping-content-existing-pdfs/watermark-examples" rel="nofollow">this</a> example as guideline, but the pdf that I created seems to be missing end-of-file markers and the 'startxref' keyword.</p>
  
  <p>Is there anything that I failed to do right? Or something that is missing?</p>
  
  <pre><code>    PdfReader reader = new PdfReader(inputPDF);
      PdfStamper stamper;
      stamper = new PdfStamper(reader, outputPDF);
      PdfContentByte under = stamper.getUnderContent(1);
      Font f = new Font(FontFamily.HELVETICA, 15);
      Phrase p = new Phrase(watermarkText, f);
      ColumnText.showTextAligned(under, Element.ALIGN_CENTER, p, 297, 550, 0);
      stamper.close();
      reader.close();
  </code></pre>
  
  <p>I checked the pdf file with <a href="https://www.pdf-online.com/" rel="nofollow">this</a> tool and these are the errors I get:</p>
  
  <pre><code>    Open file.
      0x80410108 - E - The end-of-file marker was not found.
          - File: Formular_TEST_Watermark_V1_0.pdf
      0x8041010A - E - The 'startxref' keyword or the xref position was not found.
          - File: Formular_TEST_Watermark_V1_0.pdf
      0x80410108 - E - The end-of-file marker was not found.
          - File: Formular_TEST_Watermark_V1_0.pdf
      Close file.
  </code></pre>
  
  <p>EDIT:</p>
  
  <p>The above code is CORRECT, I made a mistake later in the code when transfering the pdf back to the main application, and erroneously made the assumption I must have made a mistake when watermarking because I already transferred pdfs succesfully multiple times, and thought I wouldn't have made a mistake there. My bad.</p>
  
  <p>For completeness, inputPDF and outputPDF are a ByteArrayInputStream and a ByteArrayInputStream.</p>