Assume all entries in /Pages dictionary are /Pages when the count of items matches the reported number of pages #20359
+28
−5
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.
See thread I started here #18637 (but no replies).
I am opening this not because I expect it to be immediately accepted, but to start that conversation.
What is in this PR to start with:
Any PDF which
... will, when you ask it for Page X, will return the Xth item from that top level pages dictionary without traversing the whole structure. This assumes that a Pages dictionary with 500 things, when you say you have 500 pages, almost certainly contains 500 /Page references and nothing else. As explained in the discussion post, when rendering an interleaved PDF (where the /Page dictionary for each page is before its content), the performance hit of traversing the whole /Pages structure because we don't trust that assumption is unacceptably high.
We have been running a custom build of pdf.js in our renderer with this change for a year with no reported issues.
I understand that you could create a pathological PDF where this is intentionally untrue (in which asking for a page might theoretically return the wrong one), so the question is how much protection we need against that.