diff --git a/src/evaluator.js b/src/evaluator.js index 05be3511c..bb542b7d2 100644 --- a/src/evaluator.js +++ b/src/evaluator.js @@ -111,6 +111,17 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { EX: 'endCompat' }; + function splitCombinedOperations(operations) { + // Two operations can be combined together, trying to find which two + // operations were concatenated. + for (var i = operations.length - 1; i > 0; i--) { + var op1 = operations.substring(0, i), op2 = operations.substring(i); + if (op1 in OP_MAP && op2 in OP_MAP) + return [op1, op2]; // operations found + } + return null; + } + PartialEvaluator.prototype = { getOperatorList: function partialEvaluatorGetOperatorList(stream, resources, dependency, queue) { @@ -255,26 +266,32 @@ var PartialEvaluator = (function PartialEvaluatorClosure() { var patterns = xref.fetchIfRef(resources.get('Pattern')) || new Dict(); var parser = new Parser(new Lexer(stream), false); var res = resources; + var hasNextObj = false, nextObj; var args = [], obj; - var getObjBt = function getObjBt() { - parser = this.oldParser; - return { name: 'BT' }; - }; var TILING_PATTERN = 1, SHADING_PATTERN = 2; - while (!isEOF(obj = parser.getObj())) { + while (true) { + if (hasNextObj) { + obj = nextObj; + hasNextObj = false; + } else { + obj = parser.getObj(); + if (isEOF(obj)) + break; + } + if (isCmd(obj)) { var cmd = obj.cmd; var fn = OP_MAP[cmd]; if (!fn) { // invalid content command, trying to recover - if (cmd.substr(-2) == 'BT') { - fn = OP_MAP[cmd.substr(0, cmd.length - 2)]; - // feeding 'BT' on next interation - parser = { - getObj: getObjBt, - oldParser: parser - }; + var cmds = splitCombinedOperations(cmd); + if (cmds) { + cmd = cmds[0]; + fn = OP_MAP[cmd]; + // feeding other command on the next interation + hasNextObj = true; + nextObj = Cmd.get(cmds[1]); } } assertWellFormed(fn, 'Unknown command "' + cmd + '"'); diff --git a/test/pdfs/issue1466.pdf.link b/test/pdfs/issue1466.pdf.link new file mode 100644 index 000000000..22ebf7e2f --- /dev/null +++ b/test/pdfs/issue1466.pdf.link @@ -0,0 +1 @@ +http://web.missouri.edu/~fanxud/publications/On%20the%20performance%20quantification%20of%20resonant%20refractive%20index%20sensors.pdf diff --git a/test/test_manifest.json b/test/test_manifest.json index a4c6defcc..7d290d618 100644 --- a/test/test_manifest.json +++ b/test/test_manifest.json @@ -501,6 +501,13 @@ "link": true, "type": "eq" }, + { "id": "issue1466", + "file": "pdfs/issue1466.pdf", + "md5": "8a8877432e5bb10cfd50d60488d947bb", + "rounds": 1, + "link": true, + "type": "eq" + }, { "id": "issue1133", "file": "pdfs/issue1133.pdf", "md5": "d1b61580cb100e3df93d33703af1773a",