Annotation not shown due to obsolete generation number in indirect reference
This is a follow up to a part of Okular bug 413819, where Poppler fails to load an annotation due to an "outdated" generation number in an indirect reference by /Annots
. Mupdf and Foxit manage to load the annotation regardless of the wrong reference.
This file was last saved by Foxit. We see page 1 holds an indirect reference 74 0 R
to a Highlight Annotation, but the actual Highlight Annotation object has newer ID 74 1
(it's linking back correctly to page 1 via /P
).
74 1 obj
<< /P 1 0 R ... /Type/Annot/Subtype/Highlight >>
75 0 obj
[ 74 0 R 78 0 R 80 0 R 81 0 R 82 0 R 87 0 R ]
endobj
All objects start with generation 0 in a new document. Obviously the generation got somehow increased to 1, which could be the result of a delete and recreate operation. Whatever software did it, it forgot to update page 1 /Annots
. The array still references the Highlight Annotation using the old generation number 74 0
.
In consequence, and IMO expected, Okular, PDF.js and qpdf fail to find and show that annotation. Somewhat surprisingly, Foxit and Mupdf manage to display it.
I'm interessted in your opionions whether it's worth to consider a workaround.
- Maybe be less strict about generation number matching in
XRef::fetch(int num, int gen, int recursion)
? - Or maybe something like a reverse lookup, like "find all /Type /Annot objects in the document, then look at their /P and add them to the referenced page"?
- Or shall we just close the issue because the root cause is an inconsistent document?