Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copy.py -- "dictionary changed size during iteration" and other issues. #218

Open
dragondave opened this issue Feb 15, 2021 · 0 comments
Open

Comments

@dragondave
Copy link

dragondave commented Feb 15, 2021

I'm trying to run the example code in examples/rl2 by invoking copy.py and it's raising an error in decodegraphics.py:

  File "/home/dragon/dxw/pdfrw/examples/rl2/decodegraphics.py", line 362, in findparsefuncs
    for key, func in globals().items():
RuntimeError: dictionary changed size during iteration

And sure enough, that's what's happening. The first time a key starts with "parse_", the next line sets some variables and increases the number of globals from 67 to 68.

Working out the items ahead of time seems to get past this problem (since the new ones probably aren't "parse_") --

items = [x for x in globals().items() if x[0].startswith('parse_')]
for key, func in list(items):
    ...

I then get other errors but it's at least looking at the PDF file now (file is https://www.england.nhs.uk/commissioning/wp-content/uploads/sites/12/2013/11/N-SC023.pdf -- content is SFW but may raise eyebrows)

[WARNING] tokens.py:221 Did not find PDF object (33, 0) (line=620, col=1, token='endobj')
[WARNING] uncompress.py:46 Not decompressing: cannot use filter '/DCTDecode' with parameters None
Unparsed parameters/commands: ['/P', '<<', '/MCID', '0', '>>', 'BDC']
Traceback (most recent call last):
  File "/home/dragon/dxw/pdfrw/py3k/lib/python3.6/site-packages/reportlab/pdfbase/pdfmetrics.py", line 714, in getFont
    return _fonts[fontName]
KeyError: 'Arial'
During handling of the above exception, another exception occurred:
  File "/home/dragon/dxw/pdfrw/py3k/lib/python3.6/site-packages/reportlab/pdfbase/pdfmetrics.py", line 655, in getTypeFace
    return _typefaces[faceName]
KeyError: 'Arial'

Is this an old, out of date example or am I missing something?
pdfrw.__version__ == '0.4'

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

No branches or pull requests

1 participant