Skip to content

Error while reading bookmarks/outlines "TypeError: argument of type 'NoneType' is not iterable" #1059

@hassanseoul123

Description

@hassanseoul123

"TypeError: argument of type 'NoneType' is not iterable"
Got this when I tried to read the outlines of a PDF file with PdfReader.outlines.

Environment

Which environment were you using when you encountered the problem?

$ python -m platform
Windows-10-10.0.19044-SP0

$ python -c "import PyPDF2;print(PyPDF2.__version__)"
2.4.1

Code + PDF

Example PDF file: sample.pdf (Yes, you can use this file for tests)

from PyPDF2 import PdfReader
reader = PdfReader("sample.pdf")
print(reader.outlines)

Traceback

This is the complete Traceback I see:

C:\Users\Hassan\AppData\Local\Programs\Python\Python310\lib\site-packages\PyPDF2\_reader.py:1089: PdfReadWarning: Object 86 0 not defined.
  warnings.warn(
Traceback (most recent call last):
  File "C:\Users\Hassan\Desktop\main.py", line 3, in <module>
    outlines = reader.outlines
  File "C:\Users\Hassan\AppData\Local\Programs\Python\Python310\lib\site-packages\PyPDF2\_reader.py", line 674, in outlines
    return self._get_outlines()
  File "C:\Users\Hassan\AppData\Local\Programs\Python\Python310\lib\site-packages\PyPDF2\_reader.py", line 694, in _get_outlines
    if "/First" in lines:
TypeError: argument of type 'NoneType' is not iterable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Has MCVEA minimal, complete and verifiable example helps a lot to debug / understand feature requestsPdfReaderThe PdfReader component is affectedis-robustness-issueFrom a users perspective, this is about robustness

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions