From eaa587753b2c7cd34a95de6bcf5bb662349f36e2 Mon Sep 17 00:00:00 2001 From: Hengjie Date: Sun, 3 Aug 2014 19:55:35 +1200 Subject: [PATCH] Fix issue where pdfDocument is null Happens when no file is loaded --- web/secondary_toolbar.js | 4 +++- web/viewer.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/web/secondary_toolbar.js b/web/secondary_toolbar.js index 2775016d6f926..7b6b5858c77d6 100644 --- a/web/secondary_toolbar.js +++ b/web/secondary_toolbar.js @@ -101,7 +101,9 @@ var SecondaryToolbar = { }, lastPageClick: function secondaryToolbarLastPageClick(evt) { - PDFView.page = PDFView.pdfDocument.numPages; + if (PDFView.pdfDocument) { + PDFView.page = PDFView.pdfDocument.numPages; + } this.close(); }, diff --git a/web/viewer.js b/web/viewer.js index f44d500e33e2d..a3636645d6ac0 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -2376,8 +2376,8 @@ window.addEventListener('keydown', function keydown(evt) { } break; case 35: // end - if (PresentationMode.active || - PDFView.page < PDFView.pdfDocument.numPages) { + if (PresentationMode.active || (PDFView.pdfDocument && + PDFView.page < PDFView.pdfDocument.numPages)) { PDFView.page = PDFView.pdfDocument.numPages; handled = true; }