Skip to content

Commit

Permalink
Merge pull request #17171 from calixteman/issue17169
Browse files Browse the repository at this point in the history
Don't take into account the INVISIBLE flag for well-known annotations
  • Loading branch information
calixteman authored Oct 25, 2023
2 parents bd9b39b + 133ed96 commit 3ba68f6
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
15 changes: 14 additions & 1 deletion src/core/annotation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

/**
Expand Down Expand Up @@ -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 */
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/issue17169.pdf.link
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
https://github.com/mozilla/pdf.js/files/13161366/stamp-signature.pdf
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8181,5 +8181,13 @@
"lastPage": 2,
"type": "eq",
"forms": true
},
{
"id": "issue17169",
"file": "pdfs/issue17169.pdf",
"md5": "fa57aa9442c5e2d6d9e61bbb8856a55f",
"link": true,
"rounds": 1,
"type": "eq"
}
]
4 changes: 2 additions & 2 deletions test/unit/annotation_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
Expand Down

0 comments on commit 3ba68f6

Please sign in to comment.