title: Possible bug with load() and parse() methods in PDFBox?
body: <p>I tried to use <a href="http://pdfbox.apache.org/" rel="nofollow">PDFBox</a> on regular <code>.pdf</code> files and it worked fine. </p>
  
  <p>However when I encountered a corrupted <code>.pdf</code> , the code would "freeze" .. <em>not throwing errors or something</em> .. simply the <code>load</code> or <code>parse</code> function take forever to execute</p>
  
  <p>Here is <a href="https://dl.dropboxusercontent.com/u/41007907/MYFILE.zip" rel="nofollow">the corrupted file</a> (i have zipped it so that everybody could download it), it is probably not a native pdf file but it was saved as a <code>.pdf</code> extension and it is only 4 Kb. </p>
  
  <p>I am not an expert at all, but I think that this is a bug with PDFBox. According to documentation, both <code>load()</code> and <code>parse()</code> methods are supposed to throw exceptions if they fail. However in case with my file, the code would take forever to execute and not throw exception. </p>
  
  <p>I tried using only <code>load</code>, one can try <code>parse()</code> .. the result is the same</p>
  
  <pre><code>import java.io.FileNotFoundException;
  import java.io.IOException;
  import org.apache.pdfbox.pdmodel.PDDocument;
  import org.apache.pdfbox.util.PDFTextStripper;
  
  public class TestTest {
  
      public static void main(String[] args) throws FileNotFoundException, IOException {
          System.out.println(pdfToText("C:\\..............MYFILE.pdf")); 
          System.out.println("done ! ! !");
      }
      private static String pdfToText(String fileName) throws IOException {
          PDDocument document = null;
          document = PDDocument.load(new File(fileName)); // THIS TAKES FOREVER
          PDFTextStripper stripper = new PDFTextStripper();
          document.close();
          return stripper.getText(document);
      }
  }
  </code></pre>
  
  <p>How to force this code throw an exception or stop executing if the <code>.pdf</code> file is corrupted?
  Thanks</p>