diff --git a/src/colorspace.js b/src/colorspace.js index 26e7c1f0f..5d6eee7a7 100644 --- a/src/colorspace.js +++ b/src/colorspace.js @@ -139,6 +139,9 @@ var ColorSpace = (function ColorSpaceClosure() { var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res); var hiVal = cs[2] + 1; var lookup = xref.fetchIfRef(cs[3]); + if (isStream(lookup)) { + lookup = lookup.getBytes(); + } return ['IndexedCS', baseIndexedCS, hiVal, lookup]; case 'Separation': case 'DeviceN': @@ -260,14 +263,18 @@ var IndexedCS = (function IndexedCSClosure() { var baseNumComps = base.numComps; var length = baseNumComps * highVal; - var lookupArray = new Uint8Array(length); + var lookupArray; if (isStream(lookup)) { + lookupArray = new Uint8Array(length); var bytes = lookup.getBytes(length); lookupArray.set(bytes); } else if (isString(lookup)) { + lookupArray = new Uint8Array(length); for (var i = 0; i < length; ++i) lookupArray[i] = lookup.charCodeAt(i); + } else if (lookup instanceof Uint8Array) { + lookupArray = lookup; } else { error('Unrecognized lookup table: ' + lookup); } diff --git a/test/pdfs/issue1985.pdf b/test/pdfs/issue1985.pdf new file mode 100644 index 000000000..eca11e4a2 Binary files /dev/null and b/test/pdfs/issue1985.pdf differ diff --git a/test/test_manifest.json b/test/test_manifest.json index bfe9ad1d9..12761bd33 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -658,5 +658,11 @@ "pageLimit": 1, "link": true, "type": "load" + }, + { "id": "issue1985", + "file": "pdfs/issue1985.pdf", + "md5": "2ac7c68e26a8ef797aead15e4875cc6d", + "rounds": 1, + "type": "load" } ]