-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
PdfReader method _get_outlines()
can produce outline items with incorrect "/Title"
#1121
Comments
This is in the context of py-pdf/pypdf#1121 Co-authored-by: mtd91429 <[email protected]>
This is in the context of py-pdf/pypdf#1121 Co-authored-by: mtd91429 <[email protected]>
Thank you for the good example! I've added it to the unit tests. If anybody knows how to fix this, it's now easy to test it :-) |
I think this has to do with how Python handles pointers and the fact that the outline objects are all recycling the same named destination. Specifically, the "First" outline entry points to the named destination "section.1", as does the "Tenth" and "Nineteenth" outline entries; the "Second", "Eleventh", and "Twentieth" point to "section.2". I've been stepping through the code to determine where the error is introduced, and I think it occurs at https://github.com/py-pdf/PyPDF2/blob/ae0ff49058e6c57a8edcfcd3d956665ddaa8a787/PyPDF2/_reader.py#L837 I think I have a fix and issued a pull request #1128 |
When obtaining outlines from a PDF with bookmarks that were copied/pasted and then re-titled, some of the returned outline items point to the wrong title.
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.5.0 (commit ed5ecd9) Python 3.10
Code + PDF
This is a minimal, complete example that shows the issue:
The expected output for this file is:
Here is the PDF:
mistitled_outlines_example.pdf
Here is a screenshot of the outline in Adobe Acrobat Reader:
The text was updated successfully, but these errors were encountered: