I am trying to print lwc component to pdf, don't want to use vf page as it will require us to maintain field additions in both lwc as well as vf page. I tried using jspdf library , but can't query element and print. Below is the js function I have been trying to work,
generatePdf(){
var source = window.document.getElementsByTagName('c-org_roll-entry-details');
var specialElementHandlers = {
'#hidden-element': function (element, renderer) {
return true;
}
};
const { jsPDF } = window.jspdf;
const pdf = new jsPDF({
});
pdf.fromHTML(source, 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
pdf.save('summary.pdf');
//console.log(pdf.output('datauristring'));
}