mirror of
https://github.com/john-okeefe/foliate-js.git
synced 2026-09-09 11:29:14 -04:00
Fix bad resolution for pdfs (#23)
This commit is contained in:
@@ -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')
|
||||||
|
|||||||
Reference in New Issue
Block a user