I am using jsPDF to create PDF files from canvas. Issue is, that the created files are too big.
I used to get data from canvas to PNG and after I pasted that PNG data into PDF. If I create file in this way, it has 4.0MB
I found this question about this problem: How to reduce the file size created by JSPDF?
I rewrite my code according the answer there. So now I am using JPEG instead of PNG:
var imgData = canvas.toDataURL({
format: 'jpeg',
quality: 0.2
});
var doc = new jsPDF('p', 'mm', "A4");
doc.addImage(imgData, 'JPEG', 10, 10, 190, 190);
doc.save('mandala.pdf');
But the files have still the 4.0MB and it does not matter what quality I set for 'imgData'.
Is there a way how to reduce the size? Or 4.0 MB is the smallest I can get?