1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #6298 from viown/fix-pdf-display

Fix large PDF Display
This commit is contained in:
Bill Thornton 2024-11-05 10:39:48 -05:00 committed by GitHub
commit 048d3f1e2c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -293,12 +293,20 @@ export class PdfPlayer {
const devicePixelRatio = window.devicePixelRatio || 1; const devicePixelRatio = window.devicePixelRatio || 1;
this.book.getPage(number).then(page => { this.book.getPage(number).then(page => {
const original = page.getViewport({ scale: 1 }); 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 }); const viewport = page.getViewport({ scale });
canvas.width = viewport.width; canvas.width = viewport.width;
canvas.height = viewport.height; 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 context = canvas.getContext('2d');
const renderContext = { const renderContext = {