I am using jsPDF and it uses html2canvas to generate an image from some html element and insert on the .pdf file. But there is a problem on html2canvas, it generates blurry
I had this problem because I was on a retina display. I solved in by using MisterLamb's solution here.
$(window).load(function () {
var scaleBy = 5;
var w = 1000;
var h = 1000;
var div = document.querySelector('#screen');
var canvas = document.createElement('canvas');
canvas.width = w * scaleBy;
canvas.height = h * scaleBy;
canvas.style.width = w + 'px';
canvas.style.height = h + 'px';
var context = canvas.getContext('2d');
context.scale(scaleBy, scaleBy);
html2canvas(div, {
canvas:canvas,
onrendered: function (canvas) {
theCanvas = canvas;
document.body.appendChild(canvas);
Canvas2Image.saveAsPNG(canvas);
$(body).append(canvas);
}
});
});