From 518b776e431b239539856f01ef5881b401f80fe9 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Tue, 10 Sep 2024 15:06:51 +0200 Subject: [PATCH] Consume any pending path before drawing an annotation Fixes #18058. --- src/display/canvas.js | 5 ++++- test/pdfs/issue18058.pdf.link | 1 + test/test_manifest.json | 8 ++++++++ 3 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 test/pdfs/issue18058.pdf.link diff --git a/src/display/canvas.js b/src/display/canvas.js index 5c0b055007017..13f0790a9123b 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -2701,9 +2701,12 @@ class CanvasGraphics { } else { resetCtxToDefault(this.ctx); + // Consume a potential path before clipping. + this.endPath(); + this.ctx.rect(rect[0], rect[1], width, height); this.ctx.clip(); - this.endPath(); + this.ctx.beginPath(); } } diff --git a/test/pdfs/issue18058.pdf.link b/test/pdfs/issue18058.pdf.link new file mode 100644 index 0000000000000..b774ddf0a1724 --- /dev/null +++ b/test/pdfs/issue18058.pdf.link @@ -0,0 +1 @@ +https://github.com/mozilla/pdf.js/files/15269193/file.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index c0151de5e59ae..8a9359249228e 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -10474,5 +10474,13 @@ "pageIndex": 0 } } + }, + { + "id": "issue18058", + "file": "pdfs/issue18058.pdf", + "md5": "da8fcdf25c83ecb2d4be315be5affc3c", + "rounds": 1, + "link": true, + "type": "eq" } ]