mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-04-09 23:04:02 +02:00
Don't throw when a mesh shading is degenerated
The problem of throwing an error is that it removes an operation from drawing list which can cause a rendering issue.
This commit is contained in:
parent
394727a28c
commit
085ab36680
@ -968,20 +968,13 @@ class MeshShading extends BaseShading {
|
||||
}
|
||||
|
||||
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 [
|
||||
"Mesh",
|
||||
this.shadingType,
|
||||
this.coords,
|
||||
this.colors,
|
||||
this.figures,
|
||||
bounds,
|
||||
this.bounds,
|
||||
this.bbox,
|
||||
this.background,
|
||||
];
|
||||
|
||||
@ -462,16 +462,20 @@ class MeshShadingPattern extends BaseShadingPattern {
|
||||
const boundsWidth = Math.ceil(this._bounds[2]) - offsetX;
|
||||
const boundsHeight = Math.ceil(this._bounds[3]) - offsetY;
|
||||
|
||||
const width = Math.min(
|
||||
Math.ceil(Math.abs(boundsWidth * combinedScale[0] * EXPECTED_SCALE)),
|
||||
MAX_PATTERN_SIZE
|
||||
);
|
||||
const height = Math.min(
|
||||
Math.ceil(Math.abs(boundsHeight * combinedScale[1] * EXPECTED_SCALE)),
|
||||
MAX_PATTERN_SIZE
|
||||
);
|
||||
const scaleX = boundsWidth / width;
|
||||
const scaleY = boundsHeight / height;
|
||||
// Ensure that the shading has non-zero width and height, to prevent errors
|
||||
// in `pattern_helper.js` (fixes issue17848.pdf).
|
||||
const width =
|
||||
Math.min(
|
||||
Math.ceil(Math.abs(boundsWidth * combinedScale[0] * EXPECTED_SCALE)),
|
||||
MAX_PATTERN_SIZE
|
||||
) || 1;
|
||||
const height =
|
||||
Math.min(
|
||||
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 = {
|
||||
coords: this._coords,
|
||||
|
||||
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -884,3 +884,4 @@
|
||||
!form_two_pages.pdf
|
||||
!outlines_se.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",
|
||||
"rounds": 1,
|
||||
"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