From 1be9bbd2e1d0d53d3211d0a9e7d19051dbf77cc9 Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Tue, 3 Oct 2023 22:46:50 +0200 Subject: [PATCH] Compute correctly the bounding box of a transformed rectangle (fixes #17065) --- src/display/canvas.js | 11 +++++++---- test/pdfs/.gitignore | 1 + test/pdfs/issue17065.pdf | Bin 0 -> 3707 bytes test/test_manifest.json | 7 +++++++ 4 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 test/pdfs/issue17065.pdf diff --git a/src/display/canvas.js b/src/display/canvas.js index bae1da84f..c483e5163 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -517,10 +517,13 @@ class CanvasExtraState { updateRectMinMax(transform, rect) { const p1 = Util.applyTransform(rect, transform); const p2 = Util.applyTransform(rect.slice(2), transform); - this.minX = Math.min(this.minX, p1[0], p2[0]); - this.minY = Math.min(this.minY, p1[1], p2[1]); - this.maxX = Math.max(this.maxX, p1[0], p2[0]); - this.maxY = Math.max(this.maxY, p1[1], p2[1]); + const p3 = Util.applyTransform([rect[0], rect[3]], transform); + const p4 = Util.applyTransform([rect[2], rect[1]], transform); + + this.minX = Math.min(this.minX, p1[0], p2[0], p3[0], p4[0]); + this.minY = Math.min(this.minY, p1[1], p2[1], p3[1], p4[1]); + this.maxX = Math.max(this.maxX, p1[0], p2[0], p3[0], p4[0]); + this.maxY = Math.max(this.maxY, p1[1], p2[1], p3[1], p4[1]); } updateScalingPathMinMax(transform, minMax) { diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index bcc279054..12d64ee27 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -613,3 +613,4 @@ !empty_protected.pdf !tagged_stamp.pdf !bug1851498.pdf +!issue17065.pdf diff --git a/test/pdfs/issue17065.pdf b/test/pdfs/issue17065.pdf new file mode 100644 index 0000000000000000000000000000000000000000..ed50525e080e5a7bd7c91cc9320adf9136a21969 GIT binary patch literal 3707 zcmb_fZEV|A7iQyYL>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qVJ9yxy7hied`0>e|do~O2-}UJgOEX8y-)z3&noG7FJ@V2o@0DHeGyXvTL${j` zY)ZAC+R~I6ebsq>D|xj0@>>>saly#0Rci*wz6HyQuYdB!BjZc&zVV&&Kjt>AyX)XH z`)^xz%I>pT4|DX%Q-<$3yL-zAAAK5n?CmEG+g~ktpmXaT+lCL`YhBxXeEE5c_kM3| zC@($z#=+}-TleS|Nmi+y6$80^RtI%lTf3E(ja`# za>ykRV%LNAEJyfDgXy7--OJBUOq4MjRRv~sPtB{Iik7L8Ta)bxbe6>O3cQ|1b&m|` z1;b2+kL`OcOpJUoe4Ui#vvyh^F}lYcy>EPFzcxOqDf#g7RH72ElBcL` zunOlUJq}|ub78_D-e@um$ks6jUTRJ_m2mRI@my!dp9Xiy@QCNxagG}s8;gvI5z8rX zR8bU;7dSy^1w^a6!SvKhtLa|kFVLyGnq$~_Y$Uj#I%Ji-WEgxhGI?!kQM>FE*^+sU z(~Eiu+cZZb6!_Jcm+UFD=|uge+?WmUqp%kqGYK4WX z{_0*&KeoC$(2t4_m#hKzN{^$6HVS;K|1LREK!X*3s9Z3R{dL4Rxu@lzLx zN|Gp%;YGfUN<1`Xyofnvqp=w_J}N`cXvFan`kZFtDIEQ#*{D1dC$>S)Z^Th021o2^ zHj3xPX*NNg!A}s|;ON(ggAa!pb47s$=6a556m`e{KI}8bb&M8dC1+W1im1KZxGT+J Zi%@KuEWoa(Iv$IzD8iAdrDesc%pU?x9uoin literal 0 HcmV?d00001 diff --git a/test/test_manifest.json b/test/test_manifest.json index e3236b608..7d92433fb 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -8149,5 +8149,12 @@ "rounds": 1, "type": "eq", "annotations": true + }, + { + "id": "issue17065", + "file": "pdfs/issue17065.pdf", + "md5": "16a70b9941ba049a61612109e0e1d719", + "rounds": 1, + "type": "eq" } ]