From 1d69d95e9e92c30ebaf25d35882e26248838f250 Mon Sep 17 00:00:00 2001 From: Yury Delendik Date: Mon, 22 Sep 2014 16:29:50 -0500 Subject: [PATCH] PDF.js version 1.0.499 --- bower.json | 2 +- build/pdf.combined.js | 131 ++++++++++++++++-------------------------- build/pdf.js | 4 +- build/pdf.worker.js | 131 ++++++++++++++++-------------------------- package.json | 2 +- 5 files changed, 104 insertions(+), 166 deletions(-) diff --git a/bower.json b/bower.json index ea92bc0c6..dfbe7e1ba 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.497", + "version": "1.0.499", "keywords": [ "Mozilla", "pdf", diff --git a/build/pdf.combined.js b/build/pdf.combined.js index d4f15a6b0..0a968fdc5 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.497'; -PDFJS.build = '1e52c77'; +PDFJS.version = '1.0.499'; +PDFJS.build = '2e47b58'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -7726,22 +7726,15 @@ var PDFDocument = (function PDFDocumentClosure() { }, get linearization() { - var length = this.stream.length; - var linearization = false; - if (length) { + var linearization = null; + if (this.stream.length) { try { - linearization = new Linearization(this.stream); - if (linearization.length != length) { - linearization = false; - } + linearization = Linearization.create(this.stream); } catch (err) { if (err instanceof MissingDataException) { throw err; } - - info('The linearization data is not available ' + - 'or unreadable PDF data is found'); - linearization = false; + info(err); } } // shadow the prototype getter with a data property @@ -34197,78 +34190,54 @@ var Lexer = (function LexerClosure() { return Lexer; })(); -var Linearization = (function LinearizationClosure() { - function Linearization(stream) { - this.parser = new Parser(new Lexer(stream), false, null); - var obj1 = this.parser.getObj(); - var obj2 = this.parser.getObj(); - var obj3 = this.parser.getObj(); - this.linDict = this.parser.getObj(); - if (isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && - isDict(this.linDict)) { - var obj = this.linDict.get('Linearized'); - if (!(isNum(obj) && obj > 0)) { - this.linDict = null; - } - } - } - - Linearization.prototype = { - getInt: function Linearization_getInt(name) { - var linDict = this.linDict; - var obj; - if (isDict(linDict) && isInt(obj = linDict.get(name)) && obj > 0) { +var Linearization = { + create: function LinearizationCreate(stream) { + function getInt(name, allowZeroValue) { + var obj = linDict.get(name); + if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) { return obj; } - error('"' + name + '" field in linearization table is invalid'); - }, - getHint: function Linearization_getHint(index) { - var linDict = this.linDict; - var obj1, obj2; - if (isDict(linDict) && isArray(obj1 = linDict.get('H')) && - obj1.length >= 2 && isInt(obj2 = obj1[index]) && obj2 > 0) { - return obj2; - } - error('Hints table in linearization table is invalid: ' + index); - }, - get length() { - if (!isDict(this.linDict)) { - return 0; + throw new Error('The "' + name + '" parameter in the linearization ' + + 'dictionary is invalid.'); + } + function getHints() { + var hints = linDict.get('H'), hintsLength, item; + if (isArray(hints) && + ((hintsLength = hints.length) === 2 || hintsLength === 4)) { + for (var index = 0; index < hintsLength; index++) { + if (!(isInt(item = hints[index]) && item > 0)) { + throw new Error('Hint (' + index + + ') in the linearization dictionary is invalid.'); + } + } + return hints; } - return this.getInt('L'); - }, - get hintsOffset() { - return this.getHint(0); - }, - get hintsLength() { - return this.getHint(1); - }, - get hintsOffset2() { - return this.getHint(2); - }, - get hintsLenth2() { - return this.getHint(3); - }, - get objectNumberFirst() { - return this.getInt('O'); - }, - get endFirst() { - return this.getInt('E'); - }, - get numPages() { - return this.getInt('N'); - }, - get mainXRefEntriesOffset() { - return this.getInt('T'); - }, - get pageFirst() { - return this.getInt('P'); + throw new Error('Hint array in the linearization dictionary is invalid.'); } - }; - - return Linearization; -})(); - + var parser = new Parser(new Lexer(stream), false, null); + var obj1 = parser.getObj(); + var obj2 = parser.getObj(); + var obj3 = parser.getObj(); + var linDict = parser.getObj(); + var obj, length; + if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && + isNum(obj = linDict.get('Linearized')) && obj > 0)) { + return null; // No valid linearization dictionary found. + } else if ((length = getInt('L')) !== stream.length) { + throw new Error('The "L" parameter in the linearization dictionary ' + + 'does not equal the stream length.'); + } + return { + length: length, + hints: getHints(), + objectNumberFirst: getInt('O'), + endFirst: getInt('E'), + numPages: getInt('N'), + mainXRefEntriesOffset: getInt('T'), + pageFirst: (linDict.has('P') ? getInt('P', true) : 0) + }; + } +}; var PostScriptParser = (function PostScriptParserClosure() { diff --git a/build/pdf.js b/build/pdf.js index d27cba37b..861e2b02f 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.497'; -PDFJS.build = '1e52c77'; +PDFJS.version = '1.0.499'; +PDFJS.build = '2e47b58'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it diff --git a/build/pdf.worker.js b/build/pdf.worker.js index 940a51cda..702386ba7 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -21,8 +21,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.0.497'; -PDFJS.build = '1e52c77'; +PDFJS.version = '1.0.499'; +PDFJS.build = '2e47b58'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -2867,22 +2867,15 @@ var PDFDocument = (function PDFDocumentClosure() { }, get linearization() { - var length = this.stream.length; - var linearization = false; - if (length) { + var linearization = null; + if (this.stream.length) { try { - linearization = new Linearization(this.stream); - if (linearization.length != length) { - linearization = false; - } + linearization = Linearization.create(this.stream); } catch (err) { if (err instanceof MissingDataException) { throw err; } - - info('The linearization data is not available ' + - 'or unreadable PDF data is found'); - linearization = false; + info(err); } } // shadow the prototype getter with a data property @@ -29338,78 +29331,54 @@ var Lexer = (function LexerClosure() { return Lexer; })(); -var Linearization = (function LinearizationClosure() { - function Linearization(stream) { - this.parser = new Parser(new Lexer(stream), false, null); - var obj1 = this.parser.getObj(); - var obj2 = this.parser.getObj(); - var obj3 = this.parser.getObj(); - this.linDict = this.parser.getObj(); - if (isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && - isDict(this.linDict)) { - var obj = this.linDict.get('Linearized'); - if (!(isNum(obj) && obj > 0)) { - this.linDict = null; - } - } - } - - Linearization.prototype = { - getInt: function Linearization_getInt(name) { - var linDict = this.linDict; - var obj; - if (isDict(linDict) && isInt(obj = linDict.get(name)) && obj > 0) { +var Linearization = { + create: function LinearizationCreate(stream) { + function getInt(name, allowZeroValue) { + var obj = linDict.get(name); + if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) { return obj; } - error('"' + name + '" field in linearization table is invalid'); - }, - getHint: function Linearization_getHint(index) { - var linDict = this.linDict; - var obj1, obj2; - if (isDict(linDict) && isArray(obj1 = linDict.get('H')) && - obj1.length >= 2 && isInt(obj2 = obj1[index]) && obj2 > 0) { - return obj2; - } - error('Hints table in linearization table is invalid: ' + index); - }, - get length() { - if (!isDict(this.linDict)) { - return 0; + throw new Error('The "' + name + '" parameter in the linearization ' + + 'dictionary is invalid.'); + } + function getHints() { + var hints = linDict.get('H'), hintsLength, item; + if (isArray(hints) && + ((hintsLength = hints.length) === 2 || hintsLength === 4)) { + for (var index = 0; index < hintsLength; index++) { + if (!(isInt(item = hints[index]) && item > 0)) { + throw new Error('Hint (' + index + + ') in the linearization dictionary is invalid.'); + } + } + return hints; } - return this.getInt('L'); - }, - get hintsOffset() { - return this.getHint(0); - }, - get hintsLength() { - return this.getHint(1); - }, - get hintsOffset2() { - return this.getHint(2); - }, - get hintsLenth2() { - return this.getHint(3); - }, - get objectNumberFirst() { - return this.getInt('O'); - }, - get endFirst() { - return this.getInt('E'); - }, - get numPages() { - return this.getInt('N'); - }, - get mainXRefEntriesOffset() { - return this.getInt('T'); - }, - get pageFirst() { - return this.getInt('P'); + throw new Error('Hint array in the linearization dictionary is invalid.'); } - }; - - return Linearization; -})(); - + var parser = new Parser(new Lexer(stream), false, null); + var obj1 = parser.getObj(); + var obj2 = parser.getObj(); + var obj3 = parser.getObj(); + var linDict = parser.getObj(); + var obj, length; + if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && + isNum(obj = linDict.get('Linearized')) && obj > 0)) { + return null; // No valid linearization dictionary found. + } else if ((length = getInt('L')) !== stream.length) { + throw new Error('The "L" parameter in the linearization dictionary ' + + 'does not equal the stream length.'); + } + return { + length: length, + hints: getHints(), + objectNumberFirst: getInt('O'), + endFirst: getInt('E'), + numPages: getInt('N'), + mainXRefEntriesOffset: getInt('T'), + pageFirst: (linDict.has('P') ? getInt('P', true) : 0) + }; + } +}; var PostScriptParser = (function PostScriptParserClosure() { diff --git a/package.json b/package.json index 9f63c1520..816a133aa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.0.497", + "version": "1.0.499", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [ "Mozilla",