Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix blurry pdf player rendering for all viewport sizes #6182

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions src/plugins/pdfPlayer/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -290,22 +290,16 @@ export class PdfPlayer {
}

renderPage(canvas, number) {
const devicePixelRatio = window.devicePixelRatio || 1;
this.book.getPage(number).then(page => {
const width = dom.getWindowSize().innerWidth;
const height = dom.getWindowSize().innerHeight;
const scale = Math.ceil(window.devicePixelRatio || 1);
const original = page.getViewport({ scale: 1 });
const scale = Math.max((window.screen.height / original.height), (window.screen.width / original.width)) * devicePixelRatio;
const viewport = page.getViewport({ scale });
const context = canvas.getContext('2d');

canvas.width = viewport.width;
canvas.height = viewport.height;

if (width < height) {
canvas.style.width = '100%';
canvas.style.height = 'auto';
} else {
canvas.style.height = '100%';
canvas.style.width = 'auto';
}
const context = canvas.getContext('2d');

const renderContext = {
canvasContext: context,
Expand Down
Loading