Reputation: 9443
Im building app on top of angular5 and Im trying to add a html using jspdf.addHTML()
function combining html2canvas.
const content = this.vc_print_section.nativeElement;
html2canvas(content).then(canvas => {
const doc = new jsPDF('p', 'mm');
doc.addHTML(canvas, _ => {
doc.save('test.pdf');
});
});
But an error occurred:
ERROR Error: Uncaught (in promise): [object String]
Upvotes: 1
Views: 741
Reputation: 56
jsPDF calls html2canvas by itself in addHTML method. Correct code would have been this one :
const content = this.vc_print_section.nativeElement;
const doc = new jsPDF('p', 'mm');
doc.addHTML(canvas, _ => {
doc.save('test.pdf');
});
Even this way, if you are using the last version of html2canvas, I think it's not compatible with jsPDF. It may needs some changes in the addhtml.js plugin.
Upvotes: 1