Skip to content

Commit

Permalink
Backport pull request jellyfin#6298 from jellyfin-web/release-10.10.z
Browse files Browse the repository at this point in the history
Fix large PDF Display

Original-merge: 048d3f1

Merged-by: thornbill <[email protected]>

Backported-by: Joshua M. Boniface <[email protected]>
  • Loading branch information
viown authored and joshuaboniface committed Nov 19, 2024
1 parent f0fee2c commit b4b3028
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/plugins/pdfPlayer/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down

0 comments on commit b4b3028

Please sign in to comment.