Skip to content

Commit

Permalink
Fix bad resolution for pdfs (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
vytorrennan authored Apr 26, 2024
1 parent 5600b6c commit 28a757e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pdf.js
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,13 @@ const annotationLayerBuilderCSS = `
`

const renderPage = async (page, getImageBlob) => {
const scale = devicePixelRatio

const naturalPdfSize = page.getViewport({ scale: 1 })
const naturalPdfRatio = naturalPdfSize.width / naturalPdfSize.height
const appRatio = innerWidth / innerHeight
const pdfToAppResolutionRatio = appRatio / naturalPdfRatio

const scale = devicePixelRatio * pdfToAppResolutionRatio
const viewport = page.getViewport({ scale })

const canvas = document.createElement('canvas')
Expand Down

0 comments on commit 28a757e

Please sign in to comment.