title: Using PDFminer as a library: "AttributeError: 'NoneType' object has no attribute 'getobj'"
body: <p>I am writing a script for uploading PDF files and parsing them in the process. For the parsing i use <a href="http://www.unixuser.org/~euske/python/pdfminer/programming.html" rel="nofollow">PDFminer</a>. </p>
  
  <p>For turning the file into a PDFMiner document, i use the following function, neatly following the instructions you can find in the link above:</p>
  
  <pre><code>def load_document(self, _file = None):
      """turn the file into a PDFMiner document"""
      if _file == None:
          _file = self.options['file']
  
      parser = PDFParser(_file)
      doc = PDFDocument()
      doc.set_parser(parser)
      if self.options['password']:
          password = self.options['password']
      else:
          password = ""
      doc.initialize(password)
      if not doc.is_extractable:
          raise ValueError("PDF text extraction not allowed")
  
      return doc
  </code></pre>
  
  <p>The expected result is of course a nice <code>PDFDocument</code> instance, but instead i get an error:</p>
  
  <pre><code>Traceback (most recent call last):
    File "bzk_pdf.py", line 45, in &lt;module&gt;
      cli.run_cli(BZKPDFScraper)
    File "/home/toon/Projects/amcat/amcat/scripts/tools/cli.py", line 61, in run_cli
      instance = cls(options)
    File "/home/toon/Projects/amcat/amcat/scraping/pdf.py", line 44, in __init__
      self.doc = self.load_document()
    File "/home/toon/Projects/amcat/amcat/scraping/pdf.py", line 56, in load_document
      doc.set_parser(parser)
    File "/usr/local/lib/python2.7/dist-packages/pdfminer/pdfparser.py", line 327, in set_parser
      self.info.append(dict_value(trailer['Info']))
    File "/usr/local/lib/python2.7/dist-packages/pdfminer/pdftypes.py", line 132, in dict_value
      x = resolve1(x)
    File "/usr/local/lib/python2.7/dist-packages/pdfminer/pdftypes.py", line 60, in resolve1
      x = x.resolve()
    File "/usr/local/lib/python2.7/dist-packages/pdfminer/pdftypes.py", line 49, in resolve
      return self.doc.getobj(self.objid)
  AttributeError: 'NoneType' object has no attribute 'getobj'
  </code></pre>
  
  <p>I have no idea where to look, and i have not found anyone else with the same problem.</p>
  
  <p>Some extra info that might help:</p>
  
  <ul>
  <li>here's my test file: <a href="http://www.2shared.com/document/kM_wrI3J/testpdf.html" rel="nofollow">http://www.2shared.com/document/kM_wrI3J/testpdf.html</a></li>
  <li><code>_file</code> is a <a href="https://docs.djangoproject.com/en/1.4/ref/files/file/" rel="nofollow">django File object</a>, but using normal files has the same result</li>
  <li>pdfminer version: 'pdfminer-20110515'</li>
  <li>Django: 1.4.3 (I don't think it matters)</li>
  <li>Python 2.7.3</li>
  </ul>