diff --git a/bower.json b/bower.json index 1b985de1c..4d247b05a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.1.339", + "version": "1.1.341", "main": [ "build/pdf.js", "build/pdf.worker.js" diff --git a/build/pdf.combined.js b/build/pdf.combined.js index a81076e9b..86217d995 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.1.339'; -PDFJS.build = '0c15f8a'; +PDFJS.version = '1.1.341'; +PDFJS.build = 'd08895d'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -10012,6 +10012,19 @@ var Catalog = (function CatalogClosure() { var obj = this.catDict.get('Names'); var javaScript = []; + function appendIfJavaScriptDict(jsDict) { + var type = jsDict.get('S'); + if (!isName(type) || type.name !== 'JavaScript') { + return; + } + var js = jsDict.get('JS'); + if (isStream(js)) { + js = bytesToString(js.getBytes()); + } else if (!isString(js)) { + return; + } + javaScript.push(stringToPDFString(js)); + } if (obj && obj.has('JavaScript')) { var nameTree = new NameTree(obj.getRaw('JavaScript'), xref); var names = nameTree.getAll(); @@ -10022,36 +10035,25 @@ var Catalog = (function CatalogClosure() { // We don't really use the JavaScript right now. This code is // defensive so we don't cause errors on document load. var jsDict = names[name]; - if (!isDict(jsDict)) { - continue; - } - var type = jsDict.get('S'); - if (!isName(type) || type.name !== 'JavaScript') { - continue; - } - var js = jsDict.get('JS'); - if (!isString(js) && !isStream(js)) { - continue; - } - if (isStream(js)) { - js = bytesToString(js.getBytes()); + if (isDict(jsDict)) { + appendIfJavaScriptDict(jsDict); } - javaScript.push(stringToPDFString(js)); } } // Append OpenAction actions to javaScript array var openactionDict = this.catDict.get('OpenAction'); - if (isDict(openactionDict)) { - var objType = openactionDict.get('Type'); + if (isDict(openactionDict, 'Action')) { var actionType = openactionDict.get('S'); - var action = openactionDict.get('N'); - var isPrintAction = (isName(objType) && objType.name === 'Action' && - isName(actionType) && actionType.name === 'Named' && - isName(action) && action.name === 'Print'); - - if (isPrintAction) { - javaScript.push('print(true);'); + if (isName(actionType) && actionType.name === 'Named') { + // The named Print action is not a part of the PDF 1.7 specification, + // but is supported by many PDF readers/writers (including Adobe's). + var action = openactionDict.get('N'); + if (isName(action) && action.name === 'Print') { + javaScript.push('print({});'); + } + } else { + appendIfJavaScriptDict(openactionDict); } } diff --git a/build/pdf.js b/build/pdf.js index b48c34b78..ee6d38f84 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.1.339'; -PDFJS.build = '0c15f8a'; +PDFJS.version = '1.1.341'; +PDFJS.build = 'd08895d'; (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 ba91a00b5..b39ec3666 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -22,8 +22,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.1.339'; -PDFJS.build = '0c15f8a'; +PDFJS.version = '1.1.341'; +PDFJS.build = 'd08895d'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -3611,6 +3611,19 @@ var Catalog = (function CatalogClosure() { var obj = this.catDict.get('Names'); var javaScript = []; + function appendIfJavaScriptDict(jsDict) { + var type = jsDict.get('S'); + if (!isName(type) || type.name !== 'JavaScript') { + return; + } + var js = jsDict.get('JS'); + if (isStream(js)) { + js = bytesToString(js.getBytes()); + } else if (!isString(js)) { + return; + } + javaScript.push(stringToPDFString(js)); + } if (obj && obj.has('JavaScript')) { var nameTree = new NameTree(obj.getRaw('JavaScript'), xref); var names = nameTree.getAll(); @@ -3621,36 +3634,25 @@ var Catalog = (function CatalogClosure() { // We don't really use the JavaScript right now. This code is // defensive so we don't cause errors on document load. var jsDict = names[name]; - if (!isDict(jsDict)) { - continue; - } - var type = jsDict.get('S'); - if (!isName(type) || type.name !== 'JavaScript') { - continue; - } - var js = jsDict.get('JS'); - if (!isString(js) && !isStream(js)) { - continue; - } - if (isStream(js)) { - js = bytesToString(js.getBytes()); + if (isDict(jsDict)) { + appendIfJavaScriptDict(jsDict); } - javaScript.push(stringToPDFString(js)); } } // Append OpenAction actions to javaScript array var openactionDict = this.catDict.get('OpenAction'); - if (isDict(openactionDict)) { - var objType = openactionDict.get('Type'); + if (isDict(openactionDict, 'Action')) { var actionType = openactionDict.get('S'); - var action = openactionDict.get('N'); - var isPrintAction = (isName(objType) && objType.name === 'Action' && - isName(actionType) && actionType.name === 'Named' && - isName(action) && action.name === 'Print'); - - if (isPrintAction) { - javaScript.push('print(true);'); + if (isName(actionType) && actionType.name === 'Named') { + // The named Print action is not a part of the PDF 1.7 specification, + // but is supported by many PDF readers/writers (including Adobe's). + var action = openactionDict.get('N'); + if (isName(action) && action.name === 'Print') { + javaScript.push('print({});'); + } + } else { + appendIfJavaScriptDict(openactionDict); } } diff --git a/package.json b/package.json index 4f6ad69bb..8ed7a6e4d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.1.339", + "version": "1.1.341", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [ "Mozilla",