diff --git a/src/display/canvas.js b/src/display/canvas.js index c1c102ba1..517c552ab 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -634,6 +634,10 @@ class CanvasExtraState { this.startNewPathAndClipBox(intersect || [0, 0, 0, 0]); } + isEmptyClip() { + return this.minX === Infinity; + } + startNewPathAndClipBox(box) { this.clipBox = box; this.minX = Infinity; @@ -2434,7 +2438,7 @@ class CanvasGraphics { // TODO According to the spec we're also suppose to ignore any operators // that set color or include images while processing this type3 font. this.ctx.rect(llx, lly, urx - llx, ury - lly); - this.clip(); + this.ctx.clip(); this.endPath(); } @@ -2820,7 +2824,7 @@ class CanvasGraphics { resetCtxToDefault(this.ctx); this.ctx.rect(rect[0], rect[1], width, height); - this.clip(); + this.ctx.clip(); this.endPath(); } } @@ -3170,6 +3174,7 @@ class CanvasGraphics { // Helper functions consumePath(clipBox) { + const isEmpty = this.current.isEmptyClip(); if (this.pendingClip) { this.current.updateClipFromPath(); } @@ -3178,10 +3183,12 @@ class CanvasGraphics { } const ctx = this.ctx; if (this.pendingClip) { - if (this.pendingClip === EO_CLIP) { - ctx.clip("evenodd"); - } else { - ctx.clip(); + if (!isEmpty) { + if (this.pendingClip === EO_CLIP) { + ctx.clip("evenodd"); + } else { + ctx.clip(); + } } this.pendingClip = null; } diff --git a/test/pdfs/issue12306.pdf.link b/test/pdfs/issue12306.pdf.link new file mode 100644 index 000000000..7a734fafd --- /dev/null +++ b/test/pdfs/issue12306.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/5150027/document13-08-2020-122237.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index 3f0c41b89..298b28396 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -6362,5 +6362,13 @@ "link": true, "lastPage": 1, "type": "eq" + }, + { "id": "issue12306", + "file": "pdfs/issue12306.pdf", + "md5": "7fd05ba56791238b5a60adc6cc0e7a22", + "rounds": 1, + "link": true, + "lastPage": 1, + "type": "eq" } ]