mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-06-26 01:55:48 +02:00
Merge pull request #20897 from calixteman/empty_shading
Don't throw when a mesh shading is degenerated
This commit is contained in:
commit
83f06b4cf3
@ -968,20 +968,13 @@ class MeshShading extends BaseShading {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getIR() {
|
getIR() {
|
||||||
const { bounds } = this;
|
|
||||||
// Ensure that the shading has non-zero width and height, to prevent errors
|
|
||||||
// in `pattern_helper.js` (fixes issue17848.pdf).
|
|
||||||
if (bounds[2] - bounds[0] === 0 || bounds[3] - bounds[1] === 0) {
|
|
||||||
throw new FormatError(`Invalid MeshShading bounds: [${bounds}].`);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
"Mesh",
|
"Mesh",
|
||||||
this.shadingType,
|
this.shadingType,
|
||||||
this.coords,
|
this.coords,
|
||||||
this.colors,
|
this.colors,
|
||||||
this.figures,
|
this.figures,
|
||||||
bounds,
|
this.bounds,
|
||||||
this.bbox,
|
this.bbox,
|
||||||
this.background,
|
this.background,
|
||||||
];
|
];
|
||||||
|
|||||||
@ -462,16 +462,20 @@ class MeshShadingPattern extends BaseShadingPattern {
|
|||||||
const boundsWidth = Math.ceil(this._bounds[2]) - offsetX;
|
const boundsWidth = Math.ceil(this._bounds[2]) - offsetX;
|
||||||
const boundsHeight = Math.ceil(this._bounds[3]) - offsetY;
|
const boundsHeight = Math.ceil(this._bounds[3]) - offsetY;
|
||||||
|
|
||||||
const width = Math.min(
|
// Ensure that the shading has non-zero width and height, to prevent errors
|
||||||
Math.ceil(Math.abs(boundsWidth * combinedScale[0] * EXPECTED_SCALE)),
|
// in `pattern_helper.js` (fixes issue17848.pdf).
|
||||||
MAX_PATTERN_SIZE
|
const width =
|
||||||
);
|
Math.min(
|
||||||
const height = Math.min(
|
Math.ceil(Math.abs(boundsWidth * combinedScale[0] * EXPECTED_SCALE)),
|
||||||
Math.ceil(Math.abs(boundsHeight * combinedScale[1] * EXPECTED_SCALE)),
|
MAX_PATTERN_SIZE
|
||||||
MAX_PATTERN_SIZE
|
) || 1;
|
||||||
);
|
const height =
|
||||||
const scaleX = boundsWidth / width;
|
Math.min(
|
||||||
const scaleY = boundsHeight / height;
|
Math.ceil(Math.abs(boundsHeight * combinedScale[1] * EXPECTED_SCALE)),
|
||||||
|
MAX_PATTERN_SIZE
|
||||||
|
) || 1;
|
||||||
|
const scaleX = boundsWidth ? boundsWidth / width : 1;
|
||||||
|
const scaleY = boundsHeight ? boundsHeight / height : 1;
|
||||||
|
|
||||||
const context = {
|
const context = {
|
||||||
coords: this._coords,
|
coords: this._coords,
|
||||||
|
|||||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -884,3 +884,4 @@
|
|||||||
!form_two_pages.pdf
|
!form_two_pages.pdf
|
||||||
!outlines_se.pdf
|
!outlines_se.pdf
|
||||||
!radial_gradients.pdf
|
!radial_gradients.pdf
|
||||||
|
!mesh_shading_empty.pdf
|
||||||
|
|||||||
BIN
test/pdfs/mesh_shading_empty.pdf
Normal file
BIN
test/pdfs/mesh_shading_empty.pdf
Normal file
Binary file not shown.
@ -13998,5 +13998,12 @@
|
|||||||
"md5": "80e8bed66b83928698f008c33de47edd",
|
"md5": "80e8bed66b83928698f008c33de47edd",
|
||||||
"rounds": 1,
|
"rounds": 1,
|
||||||
"type": "eq"
|
"type": "eq"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "mesh_shading_empty",
|
||||||
|
"file": "pdfs/mesh_shading_empty.pdf",
|
||||||
|
"md5": "5a1bf9cb73010d84b47d91bb66bae27d",
|
||||||
|
"rounds": 1,
|
||||||
|
"type": "eq"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user