jsPDF icon indicating copy to clipboard operation
jsPDF copied to clipboard

Merged PDF is blur as compared to the source images used

Open vsvikram opened this issue 1 year ago • 0 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);

vsvikram avatar Mar 26 '24 04:03 vsvikram