title: iText 7 - com.itextpdf.io.IOException: PDF startxref not found
body: <p>We are trying to upgrade from iText 5 to iText 7 and saw few issues. I am getting an exception as &quot;com.itextpdf.io.IOException: PDF startxref not found.&quot; inside PdfReader#readPdf() and finally in the caller method getting an exception as <em>&quot;com.itextpdf.kernel.PdfException: Trailer not found.&quot;</em>.</p>
  <p>My use case is creating a PdfReader instance using inputSream and then creating PdfDocument from the reader and passing PdfWriter as a constructor parameter. We are trying to modify existing PDF, and the sample code is as below</p>
  <pre><code>PdfReader pdfReader = new PdfReader(inputStream);
  pdfReader.setUnethicalReading(true);
  ByteArrayOutputStream os = new ByteArrayOutputStream();
  PdfDocument pdfDocument = new PdfDocument(pdfReader, new PdfWriter(os));
  </code></pre>
  <p>What am I doing wrong and how can we fix this issue?</p>
  <p>We have a utility method that writes the output stream and creates a new PDF attachment.</p>