diff --git a/src/display/canvas.js b/src/display/canvas.js index ccca4e8545fad..d2dec4abbc8f9 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -2667,11 +2667,16 @@ const CanvasGraphics = (function CanvasGraphicsClosure() { const sqDet = (m[0] * m[3] - m[2] * m[1]) ** 2; const sqNorm1 = m[0] ** 2 + m[2] ** 2; const sqNorm2 = m[1] ** 2 + m[3] ** 2; - if (sqNorm1 !== sqNorm2 && sqNorm1 > sqDet && sqNorm2 > sqDet) { - // The parallelogram isn't a losange and both heights - // are lower than 1 so the resulting line width must be 1 + if (sqNorm1 !== sqNorm2 && (sqNorm1 > sqDet || sqNorm2 > sqDet)) { + // The parallelogram isn't a losange and at least one height + // is lower than 1 so the resulting line width must be 1 // but it cannot be achieved with one scale: when scaling a pixel // we'll get a rectangle (see issue #12295). + // For example with matrix [0.001 0, 0, 100], a pixel is transformed + // in a rectangle 0.001x100. If we just scale by 1000 (to have a 1) + // then we'll get a rectangle 1x1e5 which is wrong. + // In this case, we must reset the transform and set linewidth to 1 + // and then stroke. this._cachedGetSinglePixelWidth = -1; } else if (sqDet > Number.EPSILON ** 2) { // The multiplication by the constant 1.0000001 is here to have diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index 29d3f5034466b..2c72de34bd1cb 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -94,6 +94,7 @@ !issue11045.pdf !bug1057544.pdf !issue11150_reduced.pdf +!issue6127.pdf !issue11242_reduced.pdf !issue11279.pdf !issue11362.pdf diff --git a/test/pdfs/issue6127.pdf b/test/pdfs/issue6127.pdf new file mode 100644 index 0000000000000..198d00cb698ae Binary files /dev/null and b/test/pdfs/issue6127.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index 31b62fa6e22d9..55abbdfcb6b06 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -4877,6 +4877,13 @@ } } }, + { "id": "issue6127", + "file": "pdfs/issue6127.pdf", + "md5": "65ef9572bddef5fddfaf7172f10a0df2", + "rounds": 1, + "lastPage": 1, + "type": "eq" + }, { "id": "annotation-polyline-polygon", "file": "pdfs/annotation-polyline-polygon.pdf", "md5": "e68611602f58c8ca70cc40575ba3b04e",