title: java.io.IOException: Error: End-of-File, expected line Issue with PDFBox
body: <p>I am trying to read the PDF text from the PDF which is opened in the browser. </p>
  
  <p>After clicking on a button 'Print' the below URL opens up in the new tab.</p>
  
  <pre><code>https://myappurl.com/employees/2Jb_rpRC710XGvs8xHSOmHE9_LGkL97j/details/listprint.pdf?ids%5B%5D=2Jb_rpRC711lmIvMaBdxnzJj_ZfipcXW
  </code></pre>
  
  <p>I have executed the same program with other web URLs and found to be working fine. I have used the same code that is used here <a href="http://seleniumeasy.com/selenium-tutorials/how-to-extract-pdf-text-and-verify-using-selenium-webdriver-java" rel="noreferrer">(Extract PDF text)</a>.</p>
  
  <p>And i am using the below versions of PDFBox. </p>
  
  <pre><code>    &lt;dependency&gt;
      &lt;groupId&gt;org.apache.pdfbox&lt;/groupId&gt;
      &lt;artifactId&gt;pdfbox&lt;/artifactId&gt;
      &lt;version&gt;1.8.9&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
  &lt;dependency&gt;
      &lt;groupId&gt;org.apache.pdfbox&lt;/groupId&gt;
      &lt;artifactId&gt;fontbox&lt;/artifactId&gt;
      &lt;version&gt;1.8.9&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>Below is the code that is working fine with other URLS :</p>
  
  <pre><code>public boolean verifyPDFContent(String strURL, String reqTextInPDF) {
  
      boolean flag = false;
  
      PDFTextStripper pdfStripper = null;
      PDDocument pdDoc = null;
      COSDocument cosDoc = null;
      String parsedText = null;
  
      try {
          URL url = new URL(strURL);
          BufferedInputStream file = new BufferedInputStream(url.openStream());
          PDFParser parser = new PDFParser(file);
  
          parser.parse();
          cosDoc = parser.getDocument();
          pdfStripper = new PDFTextStripper();
          pdfStripper.setStartPage(1);
          pdfStripper.setEndPage(1);
  
          pdDoc = new PDDocument(cosDoc);
          parsedText = pdfStripper.getText(pdDoc);
      } catch (MalformedURLException e2) {
          System.err.println("URL string could not be parsed "+e2.getMessage());
      } catch (IOException e) {
          System.err.println("Unable to open PDF Parser. " + e.getMessage());
          try {
              if (cosDoc != null)
                  cosDoc.close();
              if (pdDoc != null)
                  pdDoc.close();
          } catch (Exception e1) {
              e.printStackTrace();
          }
      }
  
      System.out.println("+++++++++++++++++");
      System.out.println(parsedText);
      System.out.println("+++++++++++++++++");
  
      if(parsedText.contains(reqTextInPDF)) {
          flag=true;
      }
  
      return flag;
  }
  </code></pre>
  
  <p>And The below is the Stacktrace of the exception that im getting </p>
  
  <pre><code>java.io.IOException: Error: End-of-File, expected line
  at org.apache.pdfbox.pdfparser.BaseParser.readLine(BaseParser.java:1517)
  at org.apache.pdfbox.pdfparser.PDFParser.parseHeader(PDFParser.java:372)
  at org.apache.pdfbox.pdfparser.PDFParser.parse(PDFParser.java:186)
  at com.kareo.utils.PDFManager.getPDFContent(PDFManager.java:26)
  </code></pre>
  
  <p>Updating the image which i took when debugging at URL and File.
  <img src="https://i.stack.imgur.com/13dcL.png" alt="enter image description here">
  Please help me out. Is this something with 'https'???</p>