I was facing this problem and i solved it by using domtoimage
instead of html2canvas
.
This HTML2CANVAS
solution was not working good for me i know the scale option does increase the target div's size before capturing it but it won't work if you have something inside that div which won't resize e.g in my case it was canvas for my editing tool.
Anyway for this i opted for domtoimage
and trust me i think that this is the best solution of them all.
I didn't had to face any problem of html2canvas
for example:
need to be at the top of webpage so html2canvas
can capture the shot completely and low dpi problem
function print()
{
var node = document.getElementById('shirtDiv');
var options = {
quality: 0.95
};
domtoimage.toJpeg(node, options).then(function (dataUrl)
{
var doc = new jsPDF();
doc.addImage(dataUrl, 'JPEG', -18, 20, 240, 134.12);
doc.save('Test.pdf');
});
}
Cdn for dom to image:
https://cdnjs.com/libraries/dom-to-image
Cdn for jspdf:
https://cdnjs.com/libraries/jspdf