3

I have a report with charts and tables.
I am using the html2canvas with jsPDF to export this report to PDF file.

But the process is taking a long time, more than 11000ms.
I've tried to change the format, the quality, but nothing worked.

See below the code I used:

html2canvas($('#first-page'), {
    onrendered: function(canvas) {
        firstPage = canvas.toDataURL('image/jpeg', 0.5);
    },
    background: '#ffffff'
});


I'm doing something wrong or really is a problem?
How I can improve the performance?

Michel Makei Gefuni
  • 157
  • 1
  • 2
  • 13

1 Answers1

5

You don't need to use toDataUrl.http://jsfiddle.net/davidmather/sxp0meer/3/

html2canvas($('#first-page'), {
onrendered: function(canvas) {            
    var doc = new jsPDF('p', 'mm');
    doc.addImage(canvas, 'PNG', 10, 10);
    doc.save('sample-file.pdf');
}
});
David
  • 609
  • 1
  • 4
  • 11
  • 1
    Nice, I didn't know this. Unfortunately the problem continues, how @CBroe explained to me, toDataURL() not is the problem, but render the content onto canvas – Michel Makei Gefuni Jul 05 '17 at 14:45