Skip to content

Commit c4c24c6

Browse files
authored
Merge pull request #17070 from calixteman/17069
Update the noHTML flag to take into account the hasOwnCanvas one (fixes #17069)
2 parents 66c3b23 + 40b1d92 commit c4c24c6

File tree

4 files changed

+27
-1
lines changed

4 files changed

+27
-1
lines changed

src/core/annotation.js

+18-1
Original file line numberDiff line numberDiff line change
@@ -2845,6 +2845,7 @@ class ButtonWidgetAnnotation extends WidgetAnnotation {
28452845
this._processRadioButton(params);
28462846
} else if (this.data.pushButton) {
28472847
this.data.hasOwnCanvas = true;
2848+
this.data.noHTML = false;
28482849
this._processPushButton(params);
28492850
} else {
28502851
warn("Invalid field flags for button widget annotation");
@@ -3570,6 +3571,7 @@ class SignatureWidgetAnnotation extends WidgetAnnotation {
35703571
// to the main-thread (issue 10347).
35713572
this.data.fieldValue = null;
35723573
this.data.hasOwnCanvas = this.data.noRotate;
3574+
this.data.noHTML = !this.data.hasOwnCanvas;
35733575
}
35743576

35753577
getFieldObject() {
@@ -3591,6 +3593,7 @@ class TextAnnotation extends MarkupAnnotation {
35913593
// No rotation for Text (see 12.5.6.4).
35923594
this.data.noRotate = true;
35933595
this.data.hasOwnCanvas = this.data.noRotate;
3596+
this.data.noHTML = false;
35943597

35953598
const { dict } = params;
35963599
this.data.annotationType = AnnotationType.TEXT;
@@ -3643,6 +3646,11 @@ class PopupAnnotation extends Annotation {
36433646

36443647
const { dict } = params;
36453648
this.data.annotationType = AnnotationType.POPUP;
3649+
3650+
// A pop-up is never rendered on the main canvas so we must render its HTML
3651+
// version.
3652+
this.data.noHTML = false;
3653+
36463654
if (
36473655
this.data.rect[0] === this.data.rect[2] ||
36483656
this.data.rect[1] === this.data.rect[3]
@@ -3712,7 +3720,10 @@ class FreeTextAnnotation extends MarkupAnnotation {
37123720
constructor(params) {
37133721
super(params);
37143722

3715-
this.data.hasOwnCanvas = true;
3723+
// It uses its own canvas in order to be hidden if edited.
3724+
// But if it has the noHTML flag, it means that we don't want to be able
3725+
// to modify it so we can just draw it on the main canvas.
3726+
this.data.hasOwnCanvas = !this.data.noHTML;
37163727

37173728
const { evaluatorOptions, xref } = params;
37183729
this.data.annotationType = AnnotationType.FREETEXT;
@@ -3926,6 +3937,7 @@ class LineAnnotation extends MarkupAnnotation {
39263937
const { dict, xref } = params;
39273938
this.data.annotationType = AnnotationType.LINE;
39283939
this.data.hasOwnCanvas = this.data.noRotate;
3940+
this.data.noHTML = false;
39293941

39303942
const lineCoordinates = dict.getArray("L");
39313943
this.data.lineCoordinates = Util.normalizeRect(lineCoordinates);
@@ -3993,6 +4005,7 @@ class SquareAnnotation extends MarkupAnnotation {
39934005
const { dict, xref } = params;
39944006
this.data.annotationType = AnnotationType.SQUARE;
39954007
this.data.hasOwnCanvas = this.data.noRotate;
4008+
this.data.noHTML = false;
39964009

39974010
if (!this.appearance) {
39984011
// The default stroke color is black.
@@ -4105,6 +4118,7 @@ class PolylineAnnotation extends MarkupAnnotation {
41054118
const { dict, xref } = params;
41064119
this.data.annotationType = AnnotationType.POLYLINE;
41074120
this.data.hasOwnCanvas = this.data.noRotate;
4121+
this.data.noHTML = false;
41084122
this.data.vertices = [];
41094123

41104124
if (
@@ -4193,6 +4207,7 @@ class InkAnnotation extends MarkupAnnotation {
41934207
super(params);
41944208

41954209
this.data.hasOwnCanvas = this.data.noRotate;
4210+
this.data.noHTML = false;
41964211

41974212
const { dict, xref } = params;
41984213
this.data.annotationType = AnnotationType.INK;
@@ -4531,6 +4546,7 @@ class StampAnnotation extends MarkupAnnotation {
45314546

45324547
this.data.annotationType = AnnotationType.STAMP;
45334548
this.data.hasOwnCanvas = this.data.noRotate;
4549+
this.data.noHTML = false;
45344550
}
45354551

45364552
static async createImage(bitmap, xref) {
@@ -4680,6 +4696,7 @@ class FileAttachmentAnnotation extends MarkupAnnotation {
46804696

46814697
this.data.annotationType = AnnotationType.FILEATTACHMENT;
46824698
this.data.hasOwnCanvas = this.data.noRotate;
4699+
this.data.noHTML = false;
46834700
this.data.file = file.serializable;
46844701

46854702
const name = dict.get("Name");

test/pdfs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -615,3 +615,4 @@
615615
!tagged_stamp.pdf
616616
!bug1851498.pdf
617617
!issue17065.pdf
618+
!issue17069.pdf

test/pdfs/issue17069.pdf

690 KB
Binary file not shown.

test/test_manifest.json

+8
Original file line numberDiff line numberDiff line change
@@ -8156,5 +8156,13 @@
81568156
"md5": "16a70b9941ba049a61612109e0e1d719",
81578157
"rounds": 1,
81588158
"type": "eq"
8159+
},
8160+
{
8161+
"id": "issue17069",
8162+
"file": "pdfs/issue17069.pdf",
8163+
"md5": "e44a3920c83d8e7be112c52da4db8e57",
8164+
"rounds": 1,
8165+
"type": "eq",
8166+
"annotations": true
81598167
}
81608168
]

0 commit comments

Comments
 (0)