Skip to content

Commit 2c87a64

Browse files
committed
Fixes function array support for radial/axial pattern
1 parent 80f8f51 commit 2c87a64

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

src/pattern.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,29 @@ Shadings.RadialAxial = (function RadialAxialClosure() {
115115
this.extendEnd = extendEnd;
116116

117117
var fnObj = dict.get('Function');
118-
if (isArray(fnObj))
119-
error('No support for array of functions');
120-
if (!isPDFFunction(fnObj))
121-
error('Invalid function');
122-
var fn = PDFFunction.parse(xref, fnObj);
118+
var fn;
119+
if (isArray(fnObj)) {
120+
var fnArray = [];
121+
for (var j = 0, jj = fnObj.length; j < jj; j++) {
122+
var obj = xref.fetchIfRef(fnObj[j]);
123+
if (!isPDFFunction(obj)) {
124+
error('Invalid function');
125+
}
126+
fnArray.push(PDFFunction.parse(xref, obj));
127+
}
128+
fn = function radialAxialColorFunction(arg) {
129+
var out = [];
130+
for (var i = 0, ii = fnArray.length; i < ii; i++) {
131+
out.push(fnArray[i](arg)[0]);
132+
}
133+
return out;
134+
};
135+
} else {
136+
if (!isPDFFunction(fnObj)) {
137+
error('Invalid function');
138+
}
139+
fn = PDFFunction.parse(xref, fnObj);
140+
}
123141

124142
// 10 samples seems good enough for now, but probably won't work
125143
// if there are sharp color changes. Ideally, we would implement

test/pdfs/issue2006.pdf.link

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
http://pages.sencha.com/rs/sencha/images/Sencha-WP-Dev-Mgrs-Guide-to-HTML5.pdf

test/test_manifest.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,14 @@
713713
"link": true,
714714
"type": "eq"
715715
},
716+
{ "id": "issue2006",
717+
"file": "pdfs/issue2006.pdf",
718+
"md5": "71ec73831ece9b508ad20efa6ff28642",
719+
"rounds": 1,
720+
"pageLimit": 1,
721+
"link": true,
722+
"type": "eq"
723+
},
716724
{ "id": "issue1729",
717725
"file": "pdfs/issue1729.pdf",
718726
"md5": "29b0eddc3e1dcb23a44384037032d470",

0 commit comments

Comments
 (0)