I have a table that i want to export. It looks something like this:
This is the function:
public downloadAsPDF() {
const doc = new jsPDF();
const specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
const pdfTable = this.pdfTable.nativeElement;
doc.fromHTML(pdfTable.innerHTML, 15, 15, {
width: 190,
'elementHandlers': specialElementHandlers
});
doc.save('tableToPdf.pdf');
}
My problem is that when i export, it looks like this (It doesn't respect the formatting, the spaces):
Is there something i can do or this is normal? Thank you!
JSPDF only take care of exporting your html code if I remember well. If you don't need to interact with your pdf, then you could use html2pdf
. It uses jspdf and html2canvas to convert the given block of code into an image and then paste it in a pdf file.