From a2692bbb89ff61e0be610ee5a474f250f0f44b13 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Thu, 20 Oct 2011 18:52:04 +0200 Subject: [PATCH 1/3] Do not stop rendering on filter JPXdecode --- pdf.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pdf.js b/pdf.js index 378c17580..1488cd954 100644 --- a/pdf.js +++ b/pdf.js @@ -2959,6 +2959,8 @@ var Parser = (function parserParser() { return new AsciiHexStream(stream); } else if (name == 'CCITTFaxDecode' || name == 'CCF') { return new CCITTFaxStream(stream, params); + } else if (name == 'JPXDecode') { + warn('filter "' + name + '" not supported yet'); } else { error('filter "' + name + '" not supported yet'); } From 440e3c263fae3201a22673fa02d5011c99735a01 Mon Sep 17 00:00:00 2001 From: Vivien Nicolas <21@vingtetun.org> Date: Mon, 24 Oct 2011 10:33:23 +0200 Subject: [PATCH 2/3] TODO's all unknown filters --- pdf.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pdf.js b/pdf.js index 1488cd954..864a18384 100644 --- a/pdf.js +++ b/pdf.js @@ -2959,10 +2959,8 @@ var Parser = (function parserParser() { return new AsciiHexStream(stream); } else if (name == 'CCITTFaxDecode' || name == 'CCF') { return new CCITTFaxStream(stream, params); - } else if (name == 'JPXDecode') { - warn('filter "' + name + '" not supported yet'); } else { - error('filter "' + name + '" not supported yet'); + TODO('filter "' + name + '" not supported yet'); } return stream; } From e72216649abdf0c24cd625d35f82967e1b8438ee Mon Sep 17 00:00:00 2001 From: Kalervo Kujala Date: Mon, 24 Oct 2011 22:52:37 +0300 Subject: [PATCH 3/3] Fix strict js wanings. --- fonts.js | 3 ++- pdf.js | 30 ++++++++++++++++++------------ 2 files changed, 20 insertions(+), 13 deletions(-) diff --git a/fonts.js b/fonts.js index a604fd970..dfe1580c8 100644 --- a/fonts.js +++ b/fonts.js @@ -2631,7 +2631,8 @@ var Type2CFF = (function type2CFF() { if (unicode <= 0x1f || (unicode >= 127 && unicode <= 255)) unicode += kCmapGlyphOffset; - var width = isNum(mapping.width) ? mapping.width : defaultWidth; + var width = (mapping.hasOwnProperty('width') && isNum(mapping.width)) ? + mapping.width : defaultWidth; properties.encoding[code] = { unicode: unicode, width: width diff --git a/pdf.js b/pdf.js index a421bf961..0733dd7fc 100644 --- a/pdf.js +++ b/pdf.js @@ -4665,7 +4665,7 @@ var PartialEvaluator = (function partialEvaluator() { } var fnArray = queue.fnArray, argsArray = queue.argsArray; - var dependency = dependency || []; + var dependencyArray = dependency || []; resources = xref.fetchIfRef(resources) || new Dict(); var xobjs = xref.fetchIfRef(resources.get('XObject')) || new Dict(); @@ -4712,13 +4712,14 @@ var PartialEvaluator = (function partialEvaluator() { if (typeNum == TILING_PATTERN) { // Create an IR of the pattern code. - var depIdx = dependency.length; - var codeIR = this.getIRQueue(pattern, - dict.get('Resources'), {}, dependency); + var depIdx = dependencyArray.length; + var queueObj = {}; + var codeIR = this.getIRQueue(pattern, dict.get('Resources'), + queueObj, dependencyArray); // Add the dependencies that are required to execute the // codeIR. - insertDependency(dependency.slice(depIdx)); + insertDependency(dependencyArray.slice(depIdx)); args = TilingPattern.getIR(codeIR, dict, args); } @@ -4755,14 +4756,14 @@ var PartialEvaluator = (function partialEvaluator() { argsArray.push([matrix, bbox]); // This adds the IRQueue of the xObj to the current queue. - var depIdx = dependency.length; + var depIdx = dependencyArray.length; this.getIRQueue(xobj, xobj.dict.get('Resources'), queue, - dependency); + dependencyArray); // Add the dependencies that are required to execute the // codeIR. - insertDependency(dependency.slice(depIdx)); + insertDependency(dependencyArray.slice(depIdx)); fn = 'paintFormXObjectEnd'; args = []; @@ -5294,9 +5295,11 @@ var PartialEvaluator = (function partialEvaluator() { properties.resources = fontResources; for (var key in charProcs.map) { var glyphStream = xref.fetchIfRef(charProcs.map[key]); - var queue = {}; + var queueObj = {}; properties.glyphs[key].IRQueue = this.getIRQueue(glyphStream, - fontResources, queue, dependency); + fontResources, + queueObj, + dependency); } } @@ -7138,6 +7141,7 @@ var PDFFunction = (function() { case CONSTRUCT_STICHED: return this.constructStichedFromIR(IR); case CONSTRUCT_POSTSCRIPT: + default: return this.constructPostScriptFromIR(IR); } }, @@ -7417,7 +7421,7 @@ var PDFObjects = (function() { // not required to be resolved right now if (callback) { this.ensureObj(objId).then(callback); - return; + return null; } // If there isn't a callback, the user expects to get the resolved data @@ -7426,8 +7430,10 @@ var PDFObjects = (function() { // If there isn't an object yet or the object isn't resolved, then the // data isn't ready yet! - if (!obj || !obj.isResolved) + if (!obj || !obj.isResolved) { throw 'Requesting object that isn\'t resolved yet ' + objId; + return null; + } else return obj.data; },