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

'NoneType' object has no attribute 'get' in _mkannotation #42

Closed
0xabu opened this issue Oct 20, 2021 · 2 comments
Closed

'NoneType' object has no attribute 'get' in _mkannotation #42

0xabu opened this issue Oct 20, 2021 · 2 comments
Labels

Comments

@0xabu
Copy link
Owner

0xabu commented Oct 20, 2021

I have downloaded the folder including your last update, run an extraction from a pdf and I get back the following errors:

  File "/Users/.../pdfannots.py", line 10, in <module>
    sys.exit(main())
  File "/Users/.../pdfannots/cli.py", line 141, in main
    doc = process_file(
  File "/Users/.../pdfannots/__init__.py", line 448, in process_file
    annot = _mkannotation(pa.resolve(), page)
  File "/Users/.../pdfannots/__init__.py", line 46, in _mkannotation
    subtype = pa.get('Subtype')
AttributeError: 'NoneType' object has no attribute 'get'

The call function used is: python3 pdfannots.py "file_2017.pdf" -o notes.md --print-filename -p
The md output is blank.

Originally posted by @Chris-mik in #41 (comment)

@0xabu
Copy link
Owner Author

0xabu commented Oct 20, 2021

@Chris-mik this looks like a partly malformed PDF -- there's an entry in the page's Annots structure that does not refer to a valid object. I can change the code to ignore such entries, but would like to have a test case to check with. Are you able to share the PDF? If not, perhaps you could try to recreate the issue on a different PDF using the same annotation software?

@0xabu 0xabu added the bug label Oct 20, 2021
0xabu added a commit that referenced this issue Oct 20, 2021
Tentative fix for issue #42

Also:
 * use PSLiteral in ANNOT_SUBTYPES rather than hashing the same name strings
 * improve typing of _mkannotation, and placate mypy
@0xabu
Copy link
Owner Author

0xabu commented Dec 15, 2021

@Chris-mik, I hope the above-referenced commit fixed this crash, but would still appreciate if you could confirm that, and even better if you could share a PDF that demonstrates the issue. In the meantime, I'll close this.

@0xabu 0xabu closed this as completed Dec 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant