mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 09:20:06 +02:00
Ensure that Mesh /Shadings have non-zero width/height (issue 17848)
This commit is contained in:
parent
55db43966e
commit
07a8836ab2
5 changed files with 51 additions and 14 deletions
|
@ -1472,26 +1472,43 @@ class PartialEvaluator {
|
|||
// Shadings and patterns may be referenced by the same name but the resource
|
||||
// dictionary could be different so we can't use the name for the cache key.
|
||||
let id = localShadingPatternCache.get(shading);
|
||||
if (!id) {
|
||||
var shadingFill = Pattern.parseShading(
|
||||
if (id) {
|
||||
return id;
|
||||
}
|
||||
let patternIR;
|
||||
|
||||
try {
|
||||
const shadingFill = Pattern.parseShading(
|
||||
shading,
|
||||
this.xref,
|
||||
resources,
|
||||
this._pdfFunctionFactory,
|
||||
localColorSpaceCache
|
||||
);
|
||||
const patternIR = shadingFill.getIR();
|
||||
id = `pattern_${this.idFactory.createObjId()}`;
|
||||
if (this.parsingType3Font) {
|
||||
id = `${this.idFactory.getDocId()}_type3_${id}`;
|
||||
patternIR = shadingFill.getIR();
|
||||
} catch (reason) {
|
||||
if (reason instanceof AbortException) {
|
||||
return null;
|
||||
}
|
||||
localShadingPatternCache.set(shading, id);
|
||||
if (this.options.ignoreErrors) {
|
||||
warn(`parseShading - ignoring shading: "${reason}".`);
|
||||
|
||||
if (this.parsingType3Font) {
|
||||
this.handler.send("commonobj", [id, "Pattern", patternIR]);
|
||||
} else {
|
||||
this.handler.send("obj", [id, this.pageIndex, "Pattern", patternIR]);
|
||||
localShadingPatternCache.set(shading, null);
|
||||
return null;
|
||||
}
|
||||
throw reason;
|
||||
}
|
||||
|
||||
id = `pattern_${this.idFactory.createObjId()}`;
|
||||
if (this.parsingType3Font) {
|
||||
id = `${this.idFactory.getDocId()}_type3_${id}`;
|
||||
}
|
||||
localShadingPatternCache.set(shading, id);
|
||||
|
||||
if (this.parsingType3Font) {
|
||||
this.handler.send("commonobj", [id, "Pattern", patternIR]);
|
||||
} else {
|
||||
this.handler.send("obj", [id, this.pageIndex, "Pattern", patternIR]);
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
@ -1551,14 +1568,16 @@ class PartialEvaluator {
|
|||
);
|
||||
} else if (typeNum === PatternType.SHADING) {
|
||||
const shading = dict.get("Shading");
|
||||
const matrix = dict.getArray("Matrix");
|
||||
const objId = this.parseShading({
|
||||
shading,
|
||||
resources,
|
||||
localColorSpaceCache,
|
||||
localShadingPatternCache,
|
||||
});
|
||||
operatorList.addOp(fn, ["Shading", objId, matrix]);
|
||||
if (objId) {
|
||||
const matrix = dict.getArray("Matrix");
|
||||
operatorList.addOp(fn, ["Shading", objId, matrix]);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
throw new FormatError(`Unknown PatternType: ${typeNum}`);
|
||||
|
@ -2109,6 +2128,9 @@ class PartialEvaluator {
|
|||
localColorSpaceCache,
|
||||
localShadingPatternCache,
|
||||
});
|
||||
if (!patternId) {
|
||||
continue;
|
||||
}
|
||||
args = [patternId];
|
||||
fn = OPS.shadingFill;
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue