Skip to content

Commit

Permalink
Fallback on gray colorspace when there are no colorspace and no name …
Browse files Browse the repository at this point in the history
…in the scn/SCN arguments

It fixes #18894.
  • Loading branch information
calixteman authored and agrahn committed Oct 14, 2024
1 parent d9a38cc commit 6cc70ad
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -675,3 +675,4 @@
!stamps.pdf
!issue15096.pdf
!issue18036.pdf
!issue18894.pdf
Binary file added test/pdfs/issue18894.pdf
Binary file not shown.
8 changes: 8 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -10692,5 +10692,13 @@
"rounds": 1,
"type": "eq",
"annotations": true
},
{
"id": "issue18894",
"file": "pdfs/issue18894.pdf",
"md5": "5cd744bf8c0800e93c22ed92d1c162f4",
"rounds": 1,
"type": "eq",
"talos": false
}
]

0 comments on commit 6cc70ad

Please sign in to comment.