From 8db77cc3619b464ea724a88cd0b462dfbbb54fff Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Tue, 7 Mar 2023 12:58:59 +0100 Subject: [PATCH] Use appearance stream to render locked annotations (bug 1723568) --- src/core/annotation.js | 13 ++++++++++++- src/display/annotation_layer.js | 3 +++ test/pdfs/bug1723568.pdf.link | 2 ++ test/test_manifest.json | 9 +++++++++ 4 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/bug1723568.pdf.link diff --git a/src/core/annotation.js b/src/core/annotation.js index 331c43c9a..abd5eddcb 100644 --- a/src/core/annotation.js +++ b/src/core/annotation.js @@ -471,6 +471,12 @@ class Annotation { this._streams.push(this.appearance); } + // The annotation cannot be changed (neither its position/visibility nor its + // contents), hence we can just display its appearance and don't generate + // a HTML element for it. + const isLocked = !!(this.flags & AnnotationFlag.LOCKED); + const isContentLocked = !!(this.flags & AnnotationFlag.LOCKEDCONTENTS); + // Expose public properties using a data object. this.data = { annotationFlags: this.flags, @@ -487,6 +493,7 @@ class Annotation { subtype: params.subtype, hasOwnCanvas: false, noRotate: !!(this.flags & AnnotationFlag.NOROTATE), + noHTML: isLocked && isContentLocked, }; if (params.collectFields) { @@ -1694,7 +1701,11 @@ class WidgetAnnotation extends Annotation { ) { // Do not render form elements on the canvas when interactive forms are // enabled. The display layer is responsible for rendering them instead. - if (renderForms && !(this instanceof SignatureWidgetAnnotation)) { + if ( + renderForms && + !(this instanceof SignatureWidgetAnnotation) && + !this.data.noHTML + ) { return { opList: new OperatorList(), separateForm: true, diff --git a/src/display/annotation_layer.js b/src/display/annotation_layer.js index a70c4455b..27d44a405 100644 --- a/src/display/annotation_layer.js +++ b/src/display/annotation_layer.js @@ -2621,6 +2621,9 @@ class AnnotationLayer { let zIndex = 0; for (const data of annotations) { + if (data.noHTML) { + continue; + } if (data.annotationType !== AnnotationType.POPUP) { const { width, height } = getRectDims(data.rect); if (width <= 0 || height <= 0) { diff --git a/test/pdfs/bug1723568.pdf.link b/test/pdfs/bug1723568.pdf.link new file mode 100644 index 000000000..0a065630b --- /dev/null +++ b/test/pdfs/bug1723568.pdf.link @@ -0,0 +1,2 @@ +https://bugzilla.mozilla.org/attachment.cgi?id=9234308 + diff --git a/test/test_manifest.json b/test/test_manifest.json index 7cdb058a5..408ade6a9 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -7421,5 +7421,14 @@ "type": "eq", "annotations": true, "rotation": 270 + }, + { + "id": "bug1723568", + "file": "pdfs/bug1723568.pdf", + "md5": "c5cc9f1e01d195b96eadf8be0a819578", + "rounds": 1, + "link": true, + "type": "eq", + "forms": true } ]