parallax / jsPDF

Client-side JavaScript PDF generation for everyone.

Home Page:https://parall.ax/products/jspdf

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Merged PDF is blur as compared to the source images used

vsvikram opened this issue · comments

jsPDF version used - 2.3.0

addImage function is used to merge multiple images to PDF. This was working as expected earlier but recently the same code started resulting blur images for the same source images used earlier. Need help understanding this random behaviour.

Source code:

let freader = new FileReader(); freader.onload = f => { base64DataURL = freader.result; let imgVar = new Image(); imgVar.onload = (() => { let aspectRatio = 0.3; let context = canvas.getContext('2d'); canvas.width = imgVar.width * aspectRatio; canvas.height = imgVar.height * aspectRatio; context.drawImage(imgVar, 0, 0, canvas.width, canvas.height); let data = canvas.toDataURL(file.type, aspectRatio); let fileStart = data.indexOf(base64) + base64.length; base64File = data.substring(fileStart); this.filesUploaded.push({ Title: file.name, VersionData: encodeURIComponent(base64File), Width: canvas.width, Height: canvas.height, Format: file.type }); }); imgVar.src = base64DataURL; }; freader.readAsDataURL(file);

This issue is stale because it has been open 90 days with no activity. It will be closed soon. Please comment/reopen if this issue is still relevant.