diff --git a/src/core/pattern.js b/src/core/pattern.js
index f7fb2274f..21167f477 100644
--- a/src/core/pattern.js
+++ b/src/core/pattern.js
@@ -96,6 +96,12 @@ Shadings.RadialAxial = (function RadialAxialClosure() {
var cs = dict.get('ColorSpace', 'CS');
cs = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
this.cs = cs;
+ const bbox = dict.getArray('BBox');
+ if (Array.isArray(bbox) && bbox.length === 4) {
+ this.bbox = Util.normalizeRect(bbox);
+ } else {
+ this.bbox = null;
+ }
var t0 = 0.0, t1 = 1.0;
if (dict.has('Domain')) {
@@ -213,7 +219,7 @@ Shadings.RadialAxial = (function RadialAxialClosure() {
}
}
- return ['RadialAxial', type, this.colorStops, p0, p1, r0, r1];
+ return ['RadialAxial', type, this.bbox, this.colorStops, p0, p1, r0, r1];
},
};
@@ -719,7 +725,12 @@ Shadings.Mesh = (function MeshClosure() {
this.matrix = matrix;
this.shadingType = dict.get('ShadingType');
this.type = 'Pattern';
- this.bbox = dict.getArray('BBox');
+ const bbox = dict.getArray('BBox');
+ if (Array.isArray(bbox) && bbox.length === 4) {
+ this.bbox = Util.normalizeRect(bbox);
+ } else {
+ this.bbox = null;
+ }
var cs = dict.get('ColorSpace', 'CS');
cs = ColorSpace.parse(cs, xref, res, pdfFunctionFactory);
this.cs = cs;
diff --git a/src/display/pattern_helper.js b/src/display/pattern_helper.js
index 423deebd7..391a67cb9 100644
--- a/src/display/pattern_helper.js
+++ b/src/display/pattern_helper.js
@@ -17,17 +17,30 @@ import { FormatError, info, Util } from '../shared/util';
var ShadingIRs = {};
+function applyBoundingBox(ctx, bbox) {
+ if (!bbox || typeof Path2D === 'undefined') {
+ return;
+ }
+ const width = bbox[2] - bbox[0];
+ const height = bbox[3] - bbox[1];
+ const region = new Path2D();
+ region.rect(bbox[0], bbox[1], width, height);
+ ctx.clip(region);
+}
+
ShadingIRs.RadialAxial = {
fromIR: function RadialAxial_fromIR(raw) {
var type = raw[1];
- var colorStops = raw[2];
- var p0 = raw[3];
- var p1 = raw[4];
- var r0 = raw[5];
- var r1 = raw[6];
+ var bbox = raw[2];
+ var colorStops = raw[3];
+ var p0 = raw[4];
+ var p1 = raw[5];
+ var r0 = raw[6];
+ var r1 = raw[7];
return {
type: 'Pattern',
getPattern: function RadialAxial_getPattern(ctx) {
+ applyBoundingBox(ctx, bbox);
var grad;
if (type === 'axial') {
grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
@@ -233,11 +246,12 @@ ShadingIRs.Mesh = {
var figures = raw[4];
var bounds = raw[5];
var matrix = raw[6];
- // var bbox = raw[7];
+ var bbox = raw[7];
var background = raw[8];
return {
type: 'Pattern',
getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
+ applyBoundingBox(ctx, bbox);
var scale;
if (shadingFill) {
scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
diff --git a/test/pdfs/.gitignore b/test/pdfs/.gitignore
index b704c9682..ad58689dc 100644
--- a/test/pdfs/.gitignore
+++ b/test/pdfs/.gitignore
@@ -14,6 +14,7 @@
!issue3214.pdf
!issue4665.pdf
!issue4684.pdf
+!issue8092.pdf
!issue5256.pdf
!issue5801.pdf
!issue5946.pdf
diff --git a/test/pdfs/issue8092.pdf b/test/pdfs/issue8092.pdf
new file mode 100644
index 000000000..5c0ddb34a
--- /dev/null
+++ b/test/pdfs/issue8092.pdf
@@ -0,0 +1,151 @@
+%PDF-1.5
+%쏢
+5 0 obj
+<>
+stream
+xU0|]@,Šq)Hy`ƕd&gf0l~U((m)VxƑ!:i\XB#E~c]#n4[͂je{OOҌs,m@OFzsvXoh\ZB,6endstream
+endobj
+6 0 obj
+166
+endobj
+4 0 obj
+<>
+/Contents 5 0 R
+>>
+endobj
+3 0 obj
+<< /Type /Pages /Kids [
+4 0 R
+] /Count 1
+>>
+endobj
+1 0 obj
+<>
+endobj
+7 0 obj
+<>endobj
+8 0 obj
+[/Pattern]
+endobj
+13 0 obj
+<>
+endobj
+14 0 obj
+<>
+endobj
+15 0 obj
+<>
+endobj
+9 0 obj
+<>endobj
+16 0 obj
+<>
+endobj
+10 0 obj
+<>endobj
+17 0 obj
+<>
+endobj
+11 0 obj
+<>endobj
+12 0 obj
+<>
+endobj
+18 0 obj
+<>stream
+
+
+
+
+
+2014-07-31T04:08:37-04:00
+2014-07-31T04:08:37-04:00
+Henry McGilton for Adobe Systems Incorporated
+
+Ash02.ps
+
+
+
+
+
+endstream
+endobj
+2 0 obj
+<>endobj
+xref
+0 19
+0000000000 65535 f
+0000000540 00000 n
+0000002627 00000 n
+0000000481 00000 n
+0000000270 00000 n
+0000000015 00000 n
+0000000251 00000 n
+0000000605 00000 n
+0000000646 00000 n
+0000000762 00000 n
+0000000864 00000 n
+0000001036 00000 n
+0000001111 00000 n
+0000000672 00000 n
+0000000702 00000 n
+0000000732 00000 n
+0000000832 00000 n
+0000001004 00000 n
+0000001179 00000 n
+trailer
+<< /Size 19 /Root 1 0 R /Info 2 0 R
+/ID []
+>>
+startxref
+2823
+%%EOF
diff --git a/test/test_manifest.json b/test/test_manifest.json
index ecf7234d5..742f91689 100644
--- a/test/test_manifest.json
+++ b/test/test_manifest.json
@@ -654,6 +654,12 @@
"type": "eq",
"about": "Type1 font with |Ref|s in the Differences array of the Encoding dictionary."
},
+ { "id": "issue8092",
+ "file": "pdfs/issue8092.pdf",
+ "md5": "e4f3376b35fd132580246c3db1fbd738",
+ "rounds": 1,
+ "type": "eq"
+ },
{ "id": "franz_2",
"file": "pdfs/franz_2.pdf",
"md5": "9d301ed8816e879891115b5cc3c39559",