PDFMiner install question

MRAB python at mrabarnett.plus.com
Thu Dec 19 22:18:39 CET 2013


On 19/12/2013 19:36, Jason Mellone wrote:
> MRAB: Thank you your exact solution worked perfectly.
>
> Now I am trying to run some code from (http://www.unixuser.org/~euske/python/pdfminer/programming.html) under basic usage.
>
> If I try to run
> <code>
> from pdfminer.pdfparser import PDFParser
> from pdfminer.pdfdocument import PDFDocument
> from pdfminer.pdfpage import PDFPage
> from pdfminer.pdfpage import PDFTextExtractionNotAllowed
> from pdfminer.pdfinterp import PDFResourceManager
> from pdfminer.pdfinterp import PDFPageInterpreter
> from pdfminer.pdfdevice import PDFDevice
>
> # Open a PDF file.
> fp = open('C:\\USERS\\Python27\\samples\\test.pdf', 'rb')
> # Create a PDF parser object associated with the file object.
> parser = PDFParser(fp)
> # Create a PDF document object that stores the document structure.
> document = PDFDocument(parser)
>
> print "done"
> </code>
>
>
> I get the following error:
> PS C:\USERS\Python27> .\python.exe .\MyTest.py
> Traceback (most recent call last):
>    File ".\MyTest.py", line 4, in <module>
>      from pdfminer.pdfpage import PDFTextExtractionNotAllowed
> ImportError: cannot import name PDFTextExtractionNotAllowed
>
>
> If I run commenting out the import of "PDFTextExtractionNotAllowed" it runs without a problem. Quite odd.
>
A quick Google tokk me here:

     http://css.dzone.com/articles/pdf-reading

Its example contains:

     from pdfminer.pdfinterp import PDFResourceManager, 
PDFPageInterpreter, PDFTextExtractionNotAllowed

Note how it's importing PDFTextExtractionNotAllowed from a different
place.

Perhaps the author of the code you're looking at didn't test it. It
happens! :-)



More information about the Python-list mailing list