From e7ab8cd8c1dc6d9aa14a66f1b775994bace2107c Mon Sep 17 00:00:00 2001 From: Calixte Denizet Date: Sun, 13 Oct 2024 16:00:36 +0200 Subject: [PATCH] Fallback on gray colorspace when there are no colorspace and no name in the scn/SCN arguments It fixes #18894. --- src/core/evaluator.js | 10 ++++++++++ test/pdfs/.gitignore | 1 + test/pdfs/issue18894.pdf | Bin 0 -> 2581 bytes test/test_manifest.json | 8 ++++++++ 4 files changed, 19 insertions(+) create mode 100755 test/pdfs/issue18894.pdf diff --git a/src/core/evaluator.js b/src/core/evaluator.js index 064077fa7..c906abce5 100644 --- a/src/core/evaluator.js +++ b/src/core/evaluator.js @@ -2079,6 +2079,11 @@ class PartialEvaluator { case OPS.setFillColorN: cs = stateManager.state.patternFillColorSpace; if (!cs) { + if (isNumberArray(args, null)) { + args = ColorSpace.singletons.gray.getRgb(args, 0); + fn = OPS.setFillRGBColor; + break; + } args = []; fn = OPS.setFillTransparent; break; @@ -2106,6 +2111,11 @@ class PartialEvaluator { case OPS.setStrokeColorN: cs = stateManager.state.patternStrokeColorSpace; if (!cs) { + if (isNumberArray(args, null)) { + args = ColorSpace.singletons.gray.getRgb(args, 0); + fn = OPS.setStrokeRGBColor; + break; + } args = []; fn = OPS.setStrokeTransparent; break; diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore index c4ef395eb..fa61a789c 100644 --- a/test/pdfs/.gitignore +++ b/test/pdfs/.gitignore @@ -675,3 +675,4 @@ !stamps.pdf !issue15096.pdf !issue18036.pdf +!issue18894.pdf diff --git a/test/pdfs/issue18894.pdf b/test/pdfs/issue18894.pdf new file mode 100755 index 0000000000000000000000000000000000000000..cb2939ba8b1a6ae4dd468fc7bf2d5c63a9568588 GIT binary patch literal 2581 zcmcH*%TC)s&?;4{?y+C67bG~4-F56FmJkvoK&$cy2?weORVLX4Lt>})28I4oPd&8f ziZAG=^be#FEEm5QzsdtN&;p4aYbyS29=Ds{4Y_xY zazF(;pr+jr>|M{S+9nmYbIy*b#dd)#1UmwWQv_>UTSWQ;)bP)19?Bv3Aq3&c5;dwJ z>eG~F)p&ts3$sYG8wFaeQP?YZy`9>kf|_PCkPa+LIyhQeXF+?1rxcx<_*@*Sv!a}b@zBLjWl?c z=I(0qd? zKcU*A*#y$x416Vh6;T`aER3>_jDlI%ml1U|XWRD!74_ho+z>XzHrSyYc*Crhgk-)V!@N)}37_{Or9ToWz{7jn&jgIqQABWaDf}sjru;ZIfdVZ2qABtzoIbp`F5IGQ##e&Dm`qU|arLmxue z78E?bAHpirDw5xw!s&ZS*8^mbdVo_#E~9A;1hhQBT=L@)6jNGE zX#GDV6uKfQf3sSDEO)FWZ@j+j?C;QKm*lX1^tX+W6@LckE?91%jEh~6Auwpt9-9!D zJSmc+kMs0w<9MN?jCOB-+)pQE!N*!py6LQ|_4=+x2{f91u8kRp`xo z4RGDT8O^C>nH3WovuZh&x&>3;8+-mJkx!Z{!IHe>vI3_q4%?*9C-n`uV`up3jw`)d8yQb%T$veIl(8bjW#yYlvphHTE RR}SrOdYcdy+yeD|;twaSY9Igr literal 0 HcmV?d00001 diff --git a/test/test_manifest.json b/test/test_manifest.json index cc2bcc320..d9f045335 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -10692,5 +10692,13 @@ "rounds": 1, "type": "eq", "annotations": true + }, + { + "id": "issue18894", + "file": "pdfs/issue18894.pdf", + "md5": "5cd744bf8c0800e93c22ed92d1c162f4", + "rounds": 1, + "type": "eq", + "talos": false } ]