소스 검색

PDF.js version 1.6.271 - See mozilla/pdf.js@abc417cee924b6766a705d735c6c7d6b4656c8bd

Pdf Bot 8 년 전
부모
커밋
9e9aee9932
6개의 변경된 파일31개의 추가작업 그리고 17개의 파일을 삭제
  1. 1 1
      bower.json
  2. 3 3
      build/pdf.combined.js
  3. 3 3
      build/pdf.js
  4. 2 2
      build/pdf.worker.js
  5. 1 1
      package.json
  6. 21 7
      web/pdf_viewer.js

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "1.6.268",
+  "version": "1.6.271",
   "main": [
     "build/pdf.js",
     "build/pdf.worker.js"

+ 3 - 3
build/pdf.combined.js

@@ -24,8 +24,8 @@
 }(this, function (exports) {
   // Use strict in our context only - users might not want it
   'use strict';
-  var pdfjsVersion = '1.6.268';
-  var pdfjsBuild = 'a28a710';
+  var pdfjsVersion = '1.6.271';
+  var pdfjsBuild = 'abc417c';
   var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
   var pdfjsLibs = {};
   (function pdfjsWrapper() {
@@ -32837,7 +32837,7 @@
               if (this.data.action) {
                 this._bindNamedAction(link, this.data.action);
               } else {
-                this._bindLink(link, this.data.dest || null);
+                this._bindLink(link, this.data.dest);
               }
             }
             this.container.appendChild(link);

+ 3 - 3
build/pdf.js

@@ -24,8 +24,8 @@
 }(this, function (exports) {
   // Use strict in our context only - users might not want it
   'use strict';
-  var pdfjsVersion = '1.6.268';
-  var pdfjsBuild = 'a28a710';
+  var pdfjsVersion = '1.6.271';
+  var pdfjsBuild = 'abc417c';
   var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
   var pdfjsLibs = {};
   (function pdfjsWrapper() {
@@ -4359,7 +4359,7 @@
               if (this.data.action) {
                 this._bindNamedAction(link, this.data.action);
               } else {
-                this._bindLink(link, this.data.dest || null);
+                this._bindLink(link, this.data.dest);
               }
             }
             this.container.appendChild(link);

+ 2 - 2
build/pdf.worker.js

@@ -24,8 +24,8 @@
 }(this, function (exports) {
   // Use strict in our context only - users might not want it
   'use strict';
-  var pdfjsVersion = '1.6.268';
-  var pdfjsBuild = 'a28a710';
+  var pdfjsVersion = '1.6.271';
+  var pdfjsBuild = 'abc417c';
   var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
   var pdfjsLibs = {};
   (function pdfjsWrapper() {

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "pdfjs-dist",
-  "version": "1.6.268",
+  "version": "1.6.271",
   "main": "build/pdf.js",
   "description": "Generic build of Mozilla's PDF.js library.",
   "keywords": [

+ 21 - 7
web/pdf_viewer.js

@@ -1695,10 +1695,19 @@
             var self = this;
             var goToDestination = function (destRef) {
               // dest array looks like that: <page-ref> </XYZ|/FitXXX> <args..>
-              var pageNumber = destRef instanceof Object ? self._pagesRefCache[destRef.num + ' ' + destRef.gen + ' R'] : destRef + 1;
+              var pageNumber;
+              if (destRef instanceof Object) {
+                pageNumber = self._cachedPageNumber(destRef);
+              } else if ((destRef | 0) === destRef) {
+                // Integer
+                pageNumber = destRef + 1;
+              } else {
+                console.error('PDFLinkService_navigateTo: "' + destRef + '" is not a valid destination reference.');
+                return;
+              }
               if (pageNumber) {
-                if (pageNumber > self.pagesCount) {
-                  console.error('PDFLinkService_navigateTo: ' + 'Trying to navigate to a non-existent page.');
+                if (pageNumber < 1 || pageNumber > self.pagesCount) {
+                  console.error('PDFLinkService_navigateTo: "' + pageNumber + '" is a non-existent page number.');
                   return;
                 }
                 self.pdfViewer.scrollPageIntoView({
@@ -1715,10 +1724,11 @@
                 }
               } else {
                 self.pdfDocument.getPageIndex(destRef).then(function (pageIndex) {
-                  var pageNum = pageIndex + 1;
-                  var cacheKey = destRef.num + ' ' + destRef.gen + ' R';
-                  self._pagesRefCache[cacheKey] = pageNum;
+                  self.cachePageRef(pageIndex + 1, destRef);
                   goToDestination(destRef);
+                }).catch(function () {
+                  console.error('PDFLinkService_navigateTo: "' + destRef + '" is not a valid page reference.');
+                  return;
                 });
               }
             };
@@ -1732,9 +1742,9 @@
             destinationPromise.then(function (destination) {
               dest = destination;
               if (!(destination instanceof Array)) {
+                console.error('PDFLinkService_navigateTo: "' + destination + '" is not a valid destination array.');
                 return;
               }
-              // invalid destination
               goToDestination(destination[0]);
             });
           },
@@ -1924,6 +1934,10 @@
           cachePageRef: function PDFLinkService_cachePageRef(pageNum, pageRef) {
             var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
             this._pagesRefCache[refStr] = pageNum;
+          },
+          _cachedPageNumber: function PDFLinkService_cachedPageNumber(pageRef) {
+            var refStr = pageRef.num + ' ' + pageRef.gen + ' R';
+            return this._pagesRefCache && this._pagesRefCache[refStr] || null;
           }
         };
         function isValidExplicitDestination(dest) {