From b4b3028da162debe910abc6336a6a9fcfef8090d Mon Sep 17 00:00:00 2001 From: viown <48097677+viown@users.noreply.github.com> Date: Tue, 19 Nov 2024 15:44:09 -0500 Subject: [PATCH] Backport pull request #6298 from jellyfin-web/release-10.10.z Fix large PDF Display Original-merge: 048d3f1e2c27fe93f768c2fc82d5f20f38af785f Merged-by: thornbill Backported-by: Joshua M. Boniface --- src/plugins/pdfPlayer/plugin.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/plugins/pdfPlayer/plugin.js b/src/plugins/pdfPlayer/plugin.js index de30a73bfd..c428698659 100644 --- a/src/plugins/pdfPlayer/plugin.js +++ b/src/plugins/pdfPlayer/plugin.js @@ -293,12 +293,20 @@ export class PdfPlayer { const devicePixelRatio = window.devicePixelRatio || 1; this.book.getPage(number).then(page => { const original = page.getViewport({ scale: 1 }); - const scale = Math.max((window.screen.height / original.height), (window.screen.width / original.width)) * devicePixelRatio; + const scale = Math.min((window.innerHeight / original.height), (window.innerWidth / original.width)) * devicePixelRatio; const viewport = page.getViewport({ scale }); canvas.width = viewport.width; canvas.height = viewport.height; + if (window.innerWidth < window.innerHeight) { + canvas.style.width = '100%'; + canvas.style.height = 'auto'; + } else { + canvas.style.height = '100%'; + canvas.style.width = 'auto'; + } + const context = canvas.getContext('2d'); const renderContext = {