diff --git a/src/core/annotation.js b/src/core/annotation.js index d1516a71abeb5..6d78ea384a229 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -838,6 +838,17 @@ class Annotation { */ setFlags(flags) { this.flags = Number.isInteger(flags) && flags > 0 ? flags : 0; + if ( + this.flags & AnnotationFlag.INVISIBLE && + this.constructor.name !== "Annotation" + ) { + // From the pdf spec v1.7, section 12.5.3 (Annotation Flags): + // If set, do not display the annotation if it does not belong to one of + // the standard annotation types and no annotation handler is available. + // + // So we can remove the flag in case we have a known annotation type. + this.flags ^= AnnotationFlag.INVISIBLE; + } } /** @@ -1817,7 +1828,9 @@ class WidgetAnnotation extends Annotation { // since the visibility can be changed by js code, hence in case // it's made viewable, we should render it (with visibility set to // hidden). - return !this._hasFlag(flags, AnnotationFlag.INVISIBLE); + // We don't take into account the `INVISIBLE` flag here, since we've a known + // annotation type. + return true; } /** @inheritdoc */ diff --git a/test/pdfs/issue17169.pdf.link b/test/pdfs/issue17169.pdf.link new file mode 100644 index 0000000000000..db14c73fa8ab3 --- /dev/null +++ b/test/pdfs/issue17169.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/13161366/stamp-signature.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index f58ffb1ed339e..bcd70169b21b9 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -8181,5 +8181,13 @@ "lastPage": 2, "type": "eq", "forms": true + }, + { + "id": "issue17169", + "file": "pdfs/issue17169.pdf", + "md5": "fa57aa9442c5e2d6d9e61bbb8856a55f", + "link": true, + "rounds": 1, + "type": "eq" } ] diff --git a/test/unit/annotation_spec.js b/test/unit/annotation_spec.js index 78f323eaed1ea..6791d8419052f 100644 --- a/test/unit/annotation_spec.js +++ b/test/unit/annotation_spec.js @@ -4082,7 +4082,7 @@ describe("annotation", function () { const popupDict = new Dict(); popupDict.set("Type", Name.get("Annot")); popupDict.set("Subtype", Name.get("Popup")); - popupDict.set("F", 25); // not viewable + popupDict.set("F", 56); // not viewable popupDict.set("Parent", parentDict); const popupRef = Ref.get(13, 0); @@ -4097,7 +4097,7 @@ describe("annotation", function () { expect(data.annotationType).toEqual(AnnotationType.POPUP); // We should not modify the `annotationFlags` returned through // e.g., the API. - expect(data.annotationFlags).toEqual(25); + expect(data.annotationFlags).toEqual(56); // The popup should inherit the `viewable` property of the parent. expect(viewable).toEqual(true); }