Skip to content

Commit

Permalink
Support Blend Modes which are specified in an Array of Names (issue 1…
Browse files Browse the repository at this point in the history
…1279)

According to the specification, the first *supported* Blend Mode should be choosen in this case; please see https://www.adobe.com/content/dam/acom/en/devnet/acrobat/pdfs/PDF32000_2008.pdf#G10.4848607
  • Loading branch information
Snuffleupagus committed Oct 26, 2019
1 parent 4a5a432 commit 5c266f0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/core/evaluator.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,23 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
};

// Convert PDF blend mode names to HTML5 blend mode names.
function normalizeBlendMode(value) {
function normalizeBlendMode(value, parsingArray = false) {
if (Array.isArray(value)) {
// Use the first *supported* BM value in the Array (fixes issue11279.pdf).
for (let i = 0, ii = value.length; i < ii; i++) {
const maybeBM = normalizeBlendMode(value[i], /* parsingArray = */ true);
if (maybeBM) {
return maybeBM;
}
}
warn(`Unsupported blend mode Array: ${value}`);
return 'source-over';
}

if (!isName(value)) {
if (parsingArray) {
return null;
}
return 'source-over';
}
switch (value.name) {
Expand Down Expand Up @@ -164,7 +179,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
case 'Luminosity':
return 'luminosity';
}
warn('Unsupported blend mode: ' + value.name);
if (parsingArray) {
return null;
}
warn(`Unsupported blend mode: ${value.name}`);
return 'source-over';
}

Expand Down
1 change: 1 addition & 0 deletions test/pdfs/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
!issue11045.pdf
!issue11150_reduced.pdf
!issue11242_reduced.pdf
!issue11279.pdf
!bad-PageLabels.pdf
!decodeACSuccessive.pdf
!filled-background.pdf
Expand Down
Binary file added test/pdfs/issue11279.pdf
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -1512,6 +1512,13 @@
"link": false,
"type": "eq"
},
{ "id": "issue11279",
"file": "pdfs/issue11279.pdf",
"md5": "03361d24f3ed63b93f77abf731f8fc73",
"rounds": 1,
"link": false,
"type": "eq"
},
{ "id": "issue8480",
"file": "pdfs/issue8480.pdf",
"md5": "769bc07bf8041d95667f2d32aaf75665",
Expand Down

0 comments on commit 5c266f0

Please sign in to comment.