Allow skipping of errors when parsing broken/unsupported ColorSpaces (issue 6707, issue 11287)
This will allow us to attempt to recover as much as possible of a page, rather than immediately failing, when a broken/unsupported ColorSpace is encountered. This patch thus extends the framework added in PRs such as e.g. 8240 and 8922, to also cover parsing of ColorSpaces.
This commit is contained in:
parent
30ef05c161
commit
835d8c2be5
@ -289,11 +289,8 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
buildFormXObject: function PartialEvaluator_buildFormXObject(resources,
|
async buildFormXObject(resources, xobj, smask, operatorList, task,
|
||||||
xobj, smask,
|
initialState) {
|
||||||
operatorList,
|
|
||||||
task,
|
|
||||||
initialState) {
|
|
||||||
var dict = xobj.dict;
|
var dict = xobj.dict;
|
||||||
var matrix = dict.getArray('Matrix');
|
var matrix = dict.getArray('Matrix');
|
||||||
var bbox = dict.getArray('BBox');
|
var bbox = dict.getArray('BBox');
|
||||||
@ -318,14 +315,10 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
groupOptions.isolated = (group.get('I') || false);
|
groupOptions.isolated = (group.get('I') || false);
|
||||||
groupOptions.knockout = (group.get('K') || false);
|
groupOptions.knockout = (group.get('K') || false);
|
||||||
if (group.has('CS')) {
|
if (group.has('CS')) {
|
||||||
colorSpace = group.get('CS');
|
colorSpace = await this.parseColorSpace({
|
||||||
if (colorSpace) {
|
cs: group.get('CS'),
|
||||||
colorSpace = ColorSpace.parse(colorSpace, this.xref, resources,
|
resources,
|
||||||
this.pdfFunctionFactory);
|
});
|
||||||
} else {
|
|
||||||
warn('buildFormXObject - invalid/non-existent Group /CS entry: ' +
|
|
||||||
group.getRaw('CS'));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -934,6 +927,26 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
parseColorSpace({ cs, resources, }) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
resolve(ColorSpace.parse(cs, this.xref, resources,
|
||||||
|
this.pdfFunctionFactory));
|
||||||
|
}).catch((reason) => {
|
||||||
|
if (reason instanceof AbortException) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (this.options.ignoreErrors) {
|
||||||
|
// Error(s) in the ColorSpace -- sending unsupported feature
|
||||||
|
// notification and allow rendering to continue.
|
||||||
|
this.handler.send('UnsupportedFeature',
|
||||||
|
{ featureId: UNSUPPORTED_FEATURES.unknown, });
|
||||||
|
warn(`parseColorSpace - ignoring ColorSpace: "${reason}".`);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
throw reason;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
async handleColorN(operatorList, fn, args, cs, patterns, resources, task) {
|
async handleColorN(operatorList, fn, args, cs, patterns, resources, task) {
|
||||||
// compile tiling patterns
|
// compile tiling patterns
|
||||||
var patternName = args[args.length - 1];
|
var patternName = args[args.length - 1];
|
||||||
@ -1158,15 +1171,25 @@ var PartialEvaluator = (function PartialEvaluatorClosure() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OPS.setFillColorSpace:
|
case OPS.setFillColorSpace:
|
||||||
stateManager.state.fillColorSpace =
|
next(self.parseColorSpace({
|
||||||
ColorSpace.parse(args[0], xref, resources,
|
cs: args[0],
|
||||||
self.pdfFunctionFactory);
|
resources,
|
||||||
continue;
|
}).then(function(colorSpace) {
|
||||||
|
if (colorSpace) {
|
||||||
|
stateManager.state.fillColorSpace = colorSpace;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
return;
|
||||||
case OPS.setStrokeColorSpace:
|
case OPS.setStrokeColorSpace:
|
||||||
stateManager.state.strokeColorSpace =
|
next(self.parseColorSpace({
|
||||||
ColorSpace.parse(args[0], xref, resources,
|
cs: args[0],
|
||||||
self.pdfFunctionFactory);
|
resources,
|
||||||
continue;
|
}).then(function(colorSpace) {
|
||||||
|
if (colorSpace) {
|
||||||
|
stateManager.state.strokeColorSpace = colorSpace;
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
return;
|
||||||
case OPS.setFillColor:
|
case OPS.setFillColor:
|
||||||
cs = stateManager.state.fillColorSpace;
|
cs = stateManager.state.fillColorSpace;
|
||||||
args = cs.getRgb(args, 0);
|
args = cs.getRgb(args, 0);
|
||||||
|
1
test/pdfs/issue11287.pdf.link
Normal file
1
test/pdfs/issue11287.pdf.link
Normal file
@ -0,0 +1 @@
|
|||||||
|
https://github.com/mozilla/pdf.js/files/3786520/FLEXSTEEL.PIPELINE.TECHNOLOGIES.INC.vs.FEDON.DARREN.LOUIS.201834640.No.80265332.Texas.State.Harris.County.113th.District.Court.Jun.7.2018.pdf
|
@ -2977,6 +2977,14 @@
|
|||||||
"link": false,
|
"link": false,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
},
|
},
|
||||||
|
{ "id": "issue11287",
|
||||||
|
"file": "pdfs/issue11287.pdf",
|
||||||
|
"md5": "d7d6a7c124fad7b00f79112b71ee09d6",
|
||||||
|
"rounds": 1,
|
||||||
|
"link": true,
|
||||||
|
"lastPage": 1,
|
||||||
|
"type": "eq"
|
||||||
|
},
|
||||||
{ "id": "issue4890",
|
{ "id": "issue4890",
|
||||||
"file": "pdfs/issue4890.pdf",
|
"file": "pdfs/issue4890.pdf",
|
||||||
"md5": "1666feb4cd26318c2bdbea6a175dce87",
|
"md5": "1666feb4cd26318c2bdbea6a175dce87",
|
||||||
|
Loading…
Reference in New Issue
Block a user