Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

if 'W' in obj and 'H' in obj: TypeError: argument of type 'PSLiteral' is not iterable #97

Open
jlegaye opened this issue Feb 19, 2015 · 1 comment

Comments

@jlegaye
Copy link

jlegaye commented Feb 19, 2015

I am running this command on a 25 Mo input PDF file :

pdf2txt.py -S -t xml -o pdfMinerOutput.xml input.pdf

It crashes with this stack trace :

Traceback (most recent call last):
  File "C:\Tools\Python27\Scripts\pdf2txt.py", line 116, in <module>
    if __name__ == '__main__': sys.exit(main(sys.argv))
  File "C:\Tools\Python27\Scripts\pdf2txt.py", line 110, in main
    interpreter.process_page(page)
  File "C:\Tools\Python27\lib\site-packages\pdfminer\pdfinterp.py", line 839, in
 process_page
    self.render_contents(page.resources, page.contents, ctm=ctm)
  File "C:\Tools\Python27\lib\site-packages\pdfminer\pdfinterp.py", line 852, in
 render_contents
    self.execute(list_value(streams))
  File "C:\Tools\Python27\lib\site-packages\pdfminer\pdfinterp.py", line 877, in
 execute
    func(*args)
  File "C:\Tools\Python27\lib\site-packages\pdfminer\pdfinterp.py", line 789, in
 do_EI
    if 'W' in obj and 'H' in obj:
TypeError: argument of type 'PSLiteral' is not iterable
@adentranter
Copy link

I have had a quick look at this.

I didn't look at what the function is really doing; but all that is happening is those values are null.

I edited /usr/lib/python2.7/site-packages/pdfminer/pdfinterp.py

line 789 for me.

if 'W' in obj and 'H' in obj:

I replaced this with

if hasattr(obj,'W') and hasattr(obj,'H'):

which is a better way of checking these values.

Works perfectly.

Im going to test this method for a week with my system where we are using this library heavily. Then im going to create a PR for this.

Do you know if the owner is still adding PR?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants