From 702c860206ddf35dcad3e7d79ef70046d7fee983 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Fri, 5 Jun 2015 12:33:16 +0200 Subject: [PATCH] Ensure that pdfDocument is defined when printing (issue 6083) This patch fixes the *first* part of issue 6083 (accessing `numPages`), since that issue applies to all versions of the viewer with printing support, by ensuring that `pdfDocument` is available when printing. *Note:* The remaining issue is specific to the `mozPrintCallback` polyfill, which this patch does not touch. --- web/viewer.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/web/viewer.js b/web/viewer.js index a3db3b4717801..c1799a82e345d 100644 --- a/web/viewer.js +++ b/web/viewer.js @@ -1094,14 +1094,14 @@ var PDFViewerApplication = { beforePrint: function pdfViewSetupBeforePrint() { if (!this.supportsPrinting) { var printMessage = mozL10n.get('printing_not_supported', null, - 'Warning: Printing is not fully supported by this browser.'); + 'Warning: Printing is not fully supported by this browser.'); this.error(printMessage); return; } var alertNotReady = false; var i, ii; - if (!this.pagesCount) { + if (!this.pdfDocument || !this.pagesCount) { alertNotReady = true; } else { for (i = 0, ii = this.pagesCount; i < ii; ++i) { @@ -1113,7 +1113,7 @@ var PDFViewerApplication = { } if (alertNotReady) { var notReadyMessage = mozL10n.get('printing_not_ready', null, - 'Warning: The PDF is not fully loaded for printing.'); + 'Warning: The PDF is not fully loaded for printing.'); window.alert(notReadyMessage); return; } @@ -1125,8 +1125,8 @@ var PDFViewerApplication = { body.setAttribute('data-mozPrintCallback', true); if (!this.hasEqualPageSizes) { - console.warn('Not all pages have the same size. The printed result ' + - 'may be incorrect!'); + console.warn('Not all pages have the same size. ' + + 'The printed result may be incorrect!'); } // Insert a @page + size rule to make sure that the page size is correctly