fix resolving compressed objects in additional cross-reference table #452
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.
It looks like there is a problem with resolving compressed objects (Type==2) in additional cross-reference table (referenced by /Prev in the main one), when the main one also references it in its own stream as a Type==1 object.
The problem seems to be that the additional cross-reference table is getting added to the xrefTable with no Vaule, just position, during the precessing of the main cross-reference table object when it's a Type==1 reference.
Then when the code uses the /Prev to also processes the additional cross-reference table, it tries to add it using xrefTable.Add(iref), but that does nothing because its objectID is already in the xrefTable (with the position, and null Value).
This then hinders the mechanisms in PdfReader:
Unfortunately, I could not create a test case that I can share, because the file that revealed the bug contains data I am not allowed to share; and I'm not proficient enough with the pdf format to craft a sample pdf file from scratch.
PS: I saw that people reported an exception that look exactly as the one I was getting as issue #432, and it might be causing other hard-to-find problems if because of the missing objects.