I am trying to generate and export a PDF from HTML with Angular. i am using jspdf and html2canvas.
generatePdf() {
const data = document.querySelector('[pdfTarget]');
html2canvas(data).then(canvas => { // line (*)
const contentDataURL = canvas.toDataURL('image/png');
const pdf = new jspdf('p', 'cm', 'a4');
pdf.addImage(contentDataURL, 'PNG', 0, 0, 29.7, 21.0);
pdf.save('Filename.pdf');
});
}
if i use document.body in line (*) it works fine. but when i use querySelector or getElementById i get this error Error parsing CSS component value, unexpected EOF html2canvas.
any idea ?