fix(pdf): pdf quality and multiline #204

Merged
enes merged 2 commits from 176-178-pdf-quality-multiline into staging 2024-09-17 13:59:17 +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 pdf = await PDFJS.getDocument(data).promise
const canvas = document.createElement('canvas')
const width = getInnerContentWidth()
for (let i = 0; i < pdf.numPages; i++) {
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')
canvas.height = viewport.height
canvas.width = viewport.width
@ -106,7 +109,7 @@ export const pdfToImages = async (
await page.render({ canvasContext: context!, viewport: viewport }).promise
pages.push({
image: canvas.toDataURL(),
width: viewport.width,
width: originalViewport.width,
drawnFields: []
})
}