Support Blend Modes which are specified in an Array of Names (issue 11279)

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
This commit is contained in:
Jonas Jenwald 2019-10-26 11:57:56 +02:00
parent 4a5a4328f4
commit 5c266f0e8c
4 changed files with 28 additions and 2 deletions

View File

@ -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) {
@ -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';
}

View File

@ -85,6 +85,7 @@
!issue11045.pdf
!issue11150_reduced.pdf
!issue11242_reduced.pdf
!issue11279.pdf
!bad-PageLabels.pdf
!decodeACSuccessive.pdf
!filled-background.pdf

BIN
test/pdfs/issue11279.pdf Normal file

Binary file not shown.

View File

@ -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",