This is the below code where I am using html2canvas to convert html to pdf . Here pdf download in medium screens downloading as per expected but when same is rendered from large screens. In pdf few page coming blank content and getting shuffled order. How do I fix this issue for all screens set same.
Here is my code to pdf download.
setTimeout(()=>{
var doc = new jsPDF('l', 'mm','letter',true);
const htmlInput:any=document.querySelectorAll('.myDiv')
for(let i=0; i<htmlInput.length;i++)
{
html2canvas(htmlInput[i], {
// scale: 2,
onclone: function (clonedDoc) {
clonedDoc.getElementById("selfAssessment").style.display = "block";
},
}).then(async (canvas) => {
var imgWidth = 219;
var imgHeight = canvas.height * imgWidth / canvas.width;
doc.addImage(canvas.toDataURL('image/png'), 'PNG', 30, 10, imgWidth, imgHeight);
if(i+1==htmlInput.length)
{
doc.save('data.pdf');
}
else
{
doc.addPage()
}
});
}
},2000)