Repository navigation
Ignore only the outline whose named destination is not defined - #129
Merged
0xabu merged 2 commits intoNov 12, 2026
Merged
Conversation
One such outline stopped the outline loop, so every later outline was dropped too (460 of 530 in a real report).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When an outline refers to a named destination that the document doesn't define,
doc.get_dest()raisesPDFDestinationNotFoundinside the loop in_get_outlines().process_file()catches it and logsbut by then the generator has stopped, so every outline after that one is lost too, and annotations in those sections get no heading.
I found it with
2017.pdffrom pypdf's test files (132 pages): it has 530 outlines, 10 of which name a destination that isn't defined, and pdfannots keeps only the first 70._get_outlines()now catchesPDFDestinationNotFoundfor that one outline, logs a warning naming it, and goes on with the next one. On2017.pdfit keeps 520 outlines.tests/missing-named-destination.pdfis a small hand-written file with three outlines, the second of which names a destination that isn't in/Dests. TheMissingNamedDestinationtests check that Chapter 1 and Chapter 3 are kept and that one warning names Chapter 2; both fail on main.pytest tests.py,mypy .,flake8andautopep8 --diffpass.Used Claude (Opus) to help find and patch this; I reviewed and tested the change