From 4fffab4ad3221e7aa93c1f7bee1b0c51561d069f Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 5 May 2022 11:15:45 +0200 Subject: [PATCH] Add (basic) support for Spread modes in PresentationMode (issue 14749) After recent changes, adding *basic* Spread mode support in PresentationMode has now become reasonably straightforward. However, documents with *varying* page sizes are non-trivial to handle and would require re-writing (or at least re-factoring) a bunch of the zooming-code. Hence this PR *purposely* only allow Spread modes to be used, in PresentationMode, for documents where all pages have exactly the same size. While this obviously isn't a fully complete solution, it will however cover the vast majority of all documents and should hopefully be deemed good enough for now. --- web/pdf_presentation_mode.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/web/pdf_presentation_mode.js b/web/pdf_presentation_mode.js index 912d3a202..7da3719cb 100644 --- a/web/pdf_presentation_mode.js +++ b/web/pdf_presentation_mode.js @@ -78,9 +78,20 @@ class PDFPresentationMode { pageNumber: pdfViewer.currentPageNumber, scaleValue: pdfViewer.currentScaleValue, scrollMode: pdfViewer.scrollMode, - spreadMode: pdfViewer.spreadMode, + spreadMode: null, }; + if ( + pdfViewer.spreadMode !== SpreadMode.NONE && + !(pdfViewer.pageViewsReady && pdfViewer.hasEqualPageSizes) + ) { + console.warn( + "Ignoring Spread modes when entering PresentationMode, " + + "since the document may contain varying page sizes." + ); + this.#args.spreadMode = pdfViewer.spreadMode; + } + try { await promise; return true; @@ -151,7 +162,9 @@ class PDFPresentationMode { // Presentation Mode, by waiting until fullscreen mode in enabled. setTimeout(() => { this.pdfViewer.scrollMode = ScrollMode.PAGE; - this.pdfViewer.spreadMode = SpreadMode.NONE; + if (this.#args.spreadMode !== null) { + this.pdfViewer.spreadMode = SpreadMode.NONE; + } this.pdfViewer.currentPageNumber = this.#args.pageNumber; this.pdfViewer.currentScaleValue = "page-fit"; }, 0); @@ -177,7 +190,9 @@ class PDFPresentationMode { this.#notifyStateChange(PresentationModeState.NORMAL); this.pdfViewer.scrollMode = this.#args.scrollMode; - this.pdfViewer.spreadMode = this.#args.spreadMode; + if (this.#args.spreadMode !== null) { + this.pdfViewer.spreadMode = this.#args.spreadMode; + } this.pdfViewer.currentScaleValue = this.#args.scaleValue; this.pdfViewer.currentPageNumber = pageNumber; this.#args = null;