0

I'm trying to export an html(within a div with ID), and have managed to do so with fromHTML(), but unfortunately it doesn't read/use any css I have. This said, I tried with addHTML function, but it looks like nothing happens when I use following code:

function pdfExport(id) {
    window.html2canvas = html2canvas;
    var dddoc = new jsPDF('p', 'px', 'a4');
    var elem_to_export = $("#cmodal-id-" + id)[0];

    dddoc.addHTML(document.body, function(){
        console.log('saving');
        dddoc.save('test.pdf');
    });
}

Also, note that I don't get anything printed into console. Not sure if it's worth anything: Before I run this function pdfExport() - (it's ran onclick) - I get one get error in js console, as said image doesn't exist. Now, when I run the function, same error appears again, just as if that image is tried to be loaded again.

Milos
  • 981
  • 3
  • 16
  • 41

1 Answers1

0

This wasn't working because I used latest versions of both html2canvas and jsPDF. When I changed those to load from:

'https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js', 'https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js'

everything was just working.

Milos
  • 981
  • 3
  • 16
  • 41