Explorar o código

PDF.js version 1.6.283 - See mozilla/pdf.js@e9c63a2b3274e7fc851fcdc0761bec7eefb3f4b6

Pdf Bot %!s(int64=8) %!d(string=hai) anos
pai
achega
32d204ae52
Modificáronse 6 ficheiros con 66 adicións e 9 borrados
  1. 1 1
      bower.json
  2. 2 2
      build/pdf.combined.js
  3. 2 2
      build/pdf.js
  4. 2 2
      build/pdf.worker.js
  5. 1 1
      package.json
  6. 58 1
      web/pdf_viewer.js

+ 1 - 1
bower.json

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

+ 2 - 2
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.279';
-  var pdfjsBuild = 'a740d69';
+  var pdfjsVersion = '1.6.283';
+  var pdfjsBuild = 'e9c63a2';
   var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
   var pdfjsLibs = {};
   (function pdfjsWrapper() {

+ 2 - 2
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.279';
-  var pdfjsBuild = 'a740d69';
+  var pdfjsVersion = '1.6.283';
+  var pdfjsBuild = 'e9c63a2';
   var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
   var pdfjsLibs = {};
   (function pdfjsWrapper() {

+ 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.279';
-  var pdfjsBuild = 'a740d69';
+  var pdfjsVersion = '1.6.283';
+  var pdfjsBuild = 'e9c63a2';
   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.279",
+  "version": "1.6.283",
   "main": "build/pdf.js",
   "description": "Generic build of Mozilla's PDF.js library.",
   "keywords": [

+ 58 - 1
web/pdf_viewer.js

@@ -2096,6 +2096,7 @@
           var renderInteractiveForms = options.renderInteractiveForms || false;
           this.id = id;
           this.renderingId = 'page' + id;
+          this.pageLabel = null;
           this.rotation = 0;
           this.scale = scale || DEFAULT_SCALE;
           this.viewport = defaultViewport;
@@ -2494,6 +2495,17 @@
               self.onBeforeDraw();
             }
             return promise;
+          },
+          /**
+           * @param {string|null} label
+           */
+          setPageLabel: function PDFView_setPageLabel(label) {
+            this.pageLabel = typeof label === 'string' ? label : null;
+            if (this.pageLabel !== null) {
+              this.div.setAttribute('data-page-label', this.pageLabel);
+            } else {
+              this.div.removeAttribute('data-page-label');
+            }
           }
         };
         return PDFPageView;
@@ -3100,7 +3112,8 @@
             }
             var arg = {
               source: this,
-              pageNumber: val
+              pageNumber: val,
+              pageLabel: this._pageLabels && this._pageLabels[val - 1]
             };
             this._currentPageNumber = val;
             this.eventBus.dispatch('pagechanging', arg);
@@ -3109,6 +3122,27 @@
               this._resetCurrentPageView();
             }
           },
+          /**
+           * @returns {string|null} Returns the current page label,
+           *                        or `null` if no page labels exist.
+           */
+          get currentPageLabel() {
+            return this._pageLabels && this._pageLabels[this._currentPageNumber - 1];
+          },
+          /**
+           * @param {string} val - The page label.
+           */
+          set currentPageLabel(val) {
+            var pageNumber = val | 0;
+            // Fallback page number.
+            if (this._pageLabels) {
+              var i = this._pageLabels.indexOf(val);
+              if (i >= 0) {
+                pageNumber = i + 1;
+              }
+            }
+            this.currentPageNumber = pageNumber;
+          },
           /**
            * @returns {number}
            */
@@ -3279,11 +3313,34 @@
               }
             }.bind(this));
           },
+          /**
+           * @param {Array|null} labels
+           */
+          setPageLabels: function PDFViewer_setPageLabels(labels) {
+            if (!this.pdfDocument) {
+              return;
+            }
+            if (!labels) {
+              this._pageLabels = null;
+            } else if (!(labels instanceof Array && this.pdfDocument.numPages === labels.length)) {
+              this._pageLabels = null;
+              console.error('PDFViewer_setPageLabels: Invalid page labels.');
+            } else {
+              this._pageLabels = labels;
+            }
+            // Update all the `PDFPageView` instances.
+            for (var i = 0, ii = this._pages.length; i < ii; i++) {
+              var pageView = this._pages[i];
+              var label = this._pageLabels && this._pageLabels[i];
+              pageView.setPageLabel(label);
+            }
+          },
           _resetView: function () {
             this._pages = [];
             this._currentPageNumber = 1;
             this._currentScale = UNKNOWN_SCALE;
             this._currentScaleValue = null;
+            this._pageLabels = null;
             this._buffer = new PDFPageViewBuffer(DEFAULT_CACHE_SIZE);
             this._location = null;
             this._pagesRotation = 0;