Skip to content

Commit

Permalink
Re-add devicePixelRatio
Browse files Browse the repository at this point in the history
  • Loading branch information
viown committed Nov 4, 2024
1 parent 0ba1afa commit ea7f414
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/plugins/pdfPlayer/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,13 +291,22 @@ export class PdfPlayer {

renderPage(canvas, number) {
this.book.getPage(number).then(page => {
const devicePixelRatio = (window.devicePixelRatio || 1);
const original = page.getViewport({ scale: 1 });
const scale = Math.min((window.innerHeight / original.height), (window.innerWidth / original.width));
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 ea7f414

Please sign in to comment.