From d9cdc46f841c752b808655ca2a673ecba759a514 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Wed, 7 Dec 2022 12:18:05 +0100 Subject: [PATCH] Update the "pageviewer" example to account for the previous patches This uses a simple version number check, to prevent breakage if the example is used with older PDF.js versions. --- examples/components/pageviewer.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/components/pageviewer.js b/examples/components/pageviewer.js index b2a6ef22e..01a31161b 100644 --- a/examples/components/pageviewer.js +++ b/examples/components/pageviewer.js @@ -51,6 +51,21 @@ const loadingTask = pdfjsLib.getDocument({ const pdfDocument = await loadingTask.promise; // Document loaded, retrieving the page. const pdfPage = await pdfDocument.getPage(PAGE_TO_VIEW); + + const match = /^(\d+)\.(\d+)\.(\d+)$/.exec(pdfjsLib.version); + if (match && (match[1] | 0) >= 3 && (match[2] | 0) >= 2) { + // Creating the page view with default parameters. + const pdfPageView = new pdfjsViewer.PDFPageView({ + container, + id: PAGE_TO_VIEW, + scale: SCALE, + defaultViewport: pdfPage.getViewport({ scale: SCALE }), + eventBus, + }); + // Associate the actual page with the view, and draw it. + pdfPageView.setPdfPage(pdfPage); + return pdfPageView.draw(); + } // Creating the page view with default parameters. const pdfPageView = new pdfjsViewer.PDFPageView({ container,