New release #210

Merged
b merged 28 commits from staging into main 2024-09-19 08:23:14 +00:00
Showing only changes of commit 43beac48e8 - Show all commits

View File

@ -94,11 +94,14 @@ export const pdfToImages = async (
const pages: PdfPage[] = [] const pages: PdfPage[] = []
const pdf = await PDFJS.getDocument(data).promise const pdf = await PDFJS.getDocument(data).promise
const canvas = document.createElement('canvas') const canvas = document.createElement('canvas')
const width = getInnerContentWidth()
for (let i = 0; i < pdf.numPages; i++) { for (let i = 0; i < pdf.numPages; i++) {
const page = await pdf.getPage(i + 1) const page = await pdf.getPage(i + 1)
const viewport = page.getViewport({ scale: 1 }) const originalViewport = page.getViewport({ scale: 1 })
const scale = width / originalViewport.width
const viewport = page.getViewport({ scale: scale })
const context = canvas.getContext('2d') const context = canvas.getContext('2d')
canvas.height = viewport.height canvas.height = viewport.height
canvas.width = viewport.width canvas.width = viewport.width
@ -106,7 +109,7 @@ export const pdfToImages = async (
await page.render({ canvasContext: context!, viewport: viewport }).promise await page.render({ canvasContext: context!, viewport: viewport }).promise
pages.push({ pages.push({
image: canvas.toDataURL(), image: canvas.toDataURL(),
width: viewport.width, width: originalViewport.width,
drawnFields: [] drawnFields: []
}) })
} }