Fix bad resolution for pdfs (#23)

This commit is contained in:
Vytor Rennan
2024-04-26 03:52:21 +00:00
committed by GitHub
parent 5600b6c0dc
commit 28a757e5bb
+7 -1
View File
@@ -494,7 +494,13 @@ const annotationLayerBuilderCSS = `
` `
const renderPage = async (page, getImageBlob) => { 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 viewport = page.getViewport({ scale })
const canvas = document.createElement('canvas') const canvas = document.createElement('canvas')