From c7902dc9929076627458147cfb4ba312524f5577 Mon Sep 17 00:00:00 2001 From: Pdf Bot Date: Tue, 24 Nov 2015 18:13:16 +0000 Subject: [PATCH] PDF.js version 1.3.26 - See mozilla/pdf.js@4b243cdd89d28387ad3505c13356ca804a127b75 --- bower.json | 2 +- build/pdf.combined.js | 49 +++++++++++++++++++++++++++++++------------ build/pdf.js | 35 +++++++++++++++++++++++-------- build/pdf.worker.js | 18 ++++++++++------ package.json | 2 +- web/pdf_viewer.js | 13 ++++++++---- 6 files changed, 85 insertions(+), 34 deletions(-) diff --git a/bower.json b/bower.json index ffca6eb9d..6756caae3 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.3.24", + "version": "1.3.26", "main": [ "build/pdf.js", "build/pdf.worker.js" diff --git a/build/pdf.combined.js b/build/pdf.combined.js index 299b6fa1f..a290019d0 100644 --- a/build/pdf.combined.js +++ b/build/pdf.combined.js @@ -20,8 +20,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.3.24'; -PDFJS.build = 'dcd2812'; +PDFJS.version = '1.3.26'; +PDFJS.build = '4b243cd'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -2277,6 +2277,16 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { * @property {string} fontFamily - possible font family */ +/** + * Page annotation parameters. + * + * @typedef {Object} GetAnnotationsParameters + * @param {string} intent - Determines the annotations that will be fetched, + * can be either 'display' (viewable annotations) or 'print' + * (printable annotations). + * If the parameter is omitted, all annotations are fetched. + */ + /** * Page render parameters. * @@ -2365,12 +2375,17 @@ var PDFPageProxy = (function PDFPageProxyClosure() { return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0); }, /** + * @param {GetAnnotationsParameters} params - Annotation parameters. * @return {Promise} A promise that is resolved with an {Array} of the * annotation objects. */ - getAnnotations: function PDFPageProxy_getAnnotations() { - if (!this.annotationsPromise) { - this.annotationsPromise = this.transport.getAnnotations(this.pageIndex); + getAnnotations: function PDFPageProxy_getAnnotations(params) { + var intent = (params && params.intent) || null; + + if (!this.annotationsPromise || this.annotationsIntent !== intent) { + this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, + intent); + this.annotationsIntent = intent; } return this.annotationsPromise; }, @@ -3044,9 +3059,11 @@ var WorkerTransport = (function WorkerTransportClosure() { return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }); }, - getAnnotations: function WorkerTransport_getAnnotations(pageIndex) { - return this.messageHandler.sendWithPromise('GetAnnotations', - { pageIndex: pageIndex }); + getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) { + return this.messageHandler.sendWithPromise('GetAnnotations', { + pageIndex: pageIndex, + intent: intent, + }); }, getDestinations: function WorkerTransport_getDestinations() { @@ -3054,7 +3071,7 @@ var WorkerTransport = (function WorkerTransportClosure() { }, getDestination: function WorkerTransport_getDestination(id) { - return this.messageHandler.sendWithPromise('GetDestination', { id: id } ); + return this.messageHandler.sendWithPromise('GetDestination', { id: id }); }, getAttachments: function WorkerTransport_getAttachments() { @@ -9756,10 +9773,16 @@ var Page = (function PageClosure() { }); }, - getAnnotationsData: function Page_getAnnotationsData() { + getAnnotationsData: function Page_getAnnotationsData(intent) { var annotations = this.annotations; var annotationsData = []; for (var i = 0, n = annotations.length; i < n; ++i) { + if (intent) { + if (!(intent === 'display' && annotations[i].viewable) && + !(intent === 'print' && annotations[i].printable)) { + continue; + } + } annotationsData.push(annotations[i].data); } return annotationsData; @@ -9772,7 +9795,7 @@ var Page = (function PageClosure() { for (var i = 0, n = annotationRefs.length; i < n; ++i) { var annotationRef = annotationRefs[i]; var annotation = annotationFactory.create(this.xref, annotationRef); - if (annotation && (annotation.viewable || annotation.printable)) { + if (annotation) { annotations.push(annotation); } } @@ -41685,7 +41708,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = { handler.on('GetDestination', function wphSetupGetDestination(data) { - return pdfManager.ensureCatalog('getDestination', [ data.id ]); + return pdfManager.ensureCatalog('getDestination', [data.id]); } ); @@ -41733,7 +41756,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = { handler.on('GetAnnotations', function wphSetupGetAnnotations(data) { return pdfManager.getPage(data.pageIndex).then(function(page) { - return pdfManager.ensure(page, 'getAnnotationsData', []); + return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]); }); }); diff --git a/build/pdf.js b/build/pdf.js index a45392e9c..10bb07b72 100644 --- a/build/pdf.js +++ b/build/pdf.js @@ -20,8 +20,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.3.24'; -PDFJS.build = 'dcd2812'; +PDFJS.version = '1.3.26'; +PDFJS.build = '4b243cd'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -2286,6 +2286,16 @@ var PDFDocumentProxy = (function PDFDocumentProxyClosure() { * @property {string} fontFamily - possible font family */ +/** + * Page annotation parameters. + * + * @typedef {Object} GetAnnotationsParameters + * @param {string} intent - Determines the annotations that will be fetched, + * can be either 'display' (viewable annotations) or 'print' + * (printable annotations). + * If the parameter is omitted, all annotations are fetched. + */ + /** * Page render parameters. * @@ -2374,12 +2384,17 @@ var PDFPageProxy = (function PDFPageProxyClosure() { return new PDFJS.PageViewport(this.view, scale, rotate, 0, 0); }, /** + * @param {GetAnnotationsParameters} params - Annotation parameters. * @return {Promise} A promise that is resolved with an {Array} of the * annotation objects. */ - getAnnotations: function PDFPageProxy_getAnnotations() { - if (!this.annotationsPromise) { - this.annotationsPromise = this.transport.getAnnotations(this.pageIndex); + getAnnotations: function PDFPageProxy_getAnnotations(params) { + var intent = (params && params.intent) || null; + + if (!this.annotationsPromise || this.annotationsIntent !== intent) { + this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, + intent); + this.annotationsIntent = intent; } return this.annotationsPromise; }, @@ -3097,9 +3112,11 @@ var WorkerTransport = (function WorkerTransportClosure() { return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }); }, - getAnnotations: function WorkerTransport_getAnnotations(pageIndex) { - return this.messageHandler.sendWithPromise('GetAnnotations', - { pageIndex: pageIndex }); + getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) { + return this.messageHandler.sendWithPromise('GetAnnotations', { + pageIndex: pageIndex, + intent: intent, + }); }, getDestinations: function WorkerTransport_getDestinations() { @@ -3107,7 +3124,7 @@ var WorkerTransport = (function WorkerTransportClosure() { }, getDestination: function WorkerTransport_getDestination(id) { - return this.messageHandler.sendWithPromise('GetDestination', { id: id } ); + return this.messageHandler.sendWithPromise('GetDestination', { id: id }); }, getAttachments: function WorkerTransport_getAttachments() { diff --git a/build/pdf.worker.js b/build/pdf.worker.js index 62a4fc7af..725385bd4 100644 --- a/build/pdf.worker.js +++ b/build/pdf.worker.js @@ -20,8 +20,8 @@ if (typeof PDFJS === 'undefined') { (typeof window !== 'undefined' ? window : this).PDFJS = {}; } -PDFJS.version = '1.3.24'; -PDFJS.build = 'dcd2812'; +PDFJS.version = '1.3.26'; +PDFJS.build = '4b243cd'; (function pdfjsWrapper() { // Use strict in our context only - users might not want it @@ -2869,10 +2869,16 @@ var Page = (function PageClosure() { }); }, - getAnnotationsData: function Page_getAnnotationsData() { + getAnnotationsData: function Page_getAnnotationsData(intent) { var annotations = this.annotations; var annotationsData = []; for (var i = 0, n = annotations.length; i < n; ++i) { + if (intent) { + if (!(intent === 'display' && annotations[i].viewable) && + !(intent === 'print' && annotations[i].printable)) { + continue; + } + } annotationsData.push(annotations[i].data); } return annotationsData; @@ -2885,7 +2891,7 @@ var Page = (function PageClosure() { for (var i = 0, n = annotationRefs.length; i < n; ++i) { var annotationRef = annotationRefs[i]; var annotation = annotationFactory.create(this.xref, annotationRef); - if (annotation && (annotation.viewable || annotation.printable)) { + if (annotation) { annotations.push(annotation); } } @@ -34798,7 +34804,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = { handler.on('GetDestination', function wphSetupGetDestination(data) { - return pdfManager.ensureCatalog('getDestination', [ data.id ]); + return pdfManager.ensureCatalog('getDestination', [data.id]); } ); @@ -34846,7 +34852,7 @@ var WorkerMessageHandler = PDFJS.WorkerMessageHandler = { handler.on('GetAnnotations', function wphSetupGetAnnotations(data) { return pdfManager.getPage(data.pageIndex).then(function(page) { - return pdfManager.ensure(page, 'getAnnotationsData', []); + return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]); }); }); diff --git a/package.json b/package.json index 7c75e5903..b5b44d7de 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pdfjs-dist", - "version": "1.3.24", + "version": "1.3.26", "description": "Generic build of Mozilla's PDF.js library.", "keywords": [ "Mozilla", diff --git a/web/pdf_viewer.js b/web/pdf_viewer.js index 82dbc3ef6..4c0cb6094 100644 --- a/web/pdf_viewer.js +++ b/web/pdf_viewer.js @@ -1143,7 +1143,7 @@ var PDFPageView = (function PDFPageViewClosure() { } if (redrawAnnotations && this.annotationLayer) { - this.annotationLayer.setupAnnotations(this.viewport); + this.annotationLayer.setupAnnotations(this.viewport, 'display'); } }, @@ -1363,7 +1363,7 @@ var PDFPageView = (function PDFPageViewClosure() { this.annotationLayer = this.annotationsLayerFactory. createAnnotationsLayerBuilder(div, this.pdfPage); } - this.annotationLayer.setupAnnotations(this.viewport); + this.annotationLayer.setupAnnotations(this.viewport, 'display'); } div.setAttribute('data-loaded', true); @@ -1794,9 +1794,10 @@ var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() { /** * @param {PageViewport} viewport + * @param {string} intent (default value is 'display') */ setupAnnotations: - function AnnotationsLayerBuilder_setupAnnotations(viewport) { + function AnnotationsLayerBuilder_setupAnnotations(viewport, intent) { function bindLink(link, dest) { link.href = linkService.getDestinationHash(dest); link.onclick = function annotationsLayerBuilderLinksOnclick() { @@ -1822,8 +1823,12 @@ var AnnotationsLayerBuilder = (function AnnotationsLayerBuilderClosure() { var linkService = this.linkService; var pdfPage = this.pdfPage; var self = this; + var getAnnotationsParams = { + intent: (intent === undefined ? 'display' : intent), + }; - pdfPage.getAnnotations().then(function (annotationsData) { + pdfPage.getAnnotations(getAnnotationsParams).then( + function (annotationsData) { viewport = viewport.clone({ dontFlip: true }); var transform = viewport.transform; var transformStr = 'matrix(' + transform.join(',') + ')';