Recently, I had been asked by a client that they require to download all CRM Records of all entity as PDF.
I tried with html2canvas and jspdf libraries , but i was not able to download the form completely(form was scroll-able), It gave me only what i was able to currently see, not the remaining scrollable part.
Please guide me if i am doing something wrong in the below code or there is any other way to do so.
function createPDF() {
var a4 = [595.28, 841.89];
var div = $('#HeaderTilesWrapperLayoutElement', window.parent.document);
var xxxx = $($(div.context).find('iframe')[0]).contents().find("body");
var xxx = xxxx.find("#tdAreas");
var cache_width = xxx.width();
$('body').scrollTop(0);
getCanvas().then(function (canvas) {
var
img = canvas.toDataURL("image/png"),
doc = new jsPDF({
unit: 'px',
format: 'a4'
});
doc.addImage(img, 'JPEG', 20, 20);
doc.save('techumber-html-to-pdf.pdf');
xxx.width((a4[0] * 1.33333) - 80).css('max-width', 'none');
});
}
// create canvas object
function getCanvas() {
xxx.width((a4[0] * 1.33333) - 80).css('max-width', 'none');
return html2canvas(xxx, {
imageTimeout: 2000,
removeContainer: true
});
}