Multiple pages html2canvas and jspdf

0

In my code I decrease the (dynamic) content to the default a4 and export to pdf, only it appears in only 1 page, that is, if I retune a large content, the page is cut. I would like the image to be cut and appear on the following pages:

var cache_width = $('#toda').width(); //Criado um cache do CSS
var a4  =[ 595.28,  841.89]; // Widht e Height de uma folha a4

function getPDF(){
// Setar o width da div no formato a4
$("#toda").width((a4[0]*1.33333) -80).css('max-width','none');

// Aqui ele cria a imagem e cria o pdf
html2canvas($('#toda'), {
  onrendered: function(canvas) {
    var img = canvas.toDataURL("image/png",1.0);  
    var doc = new jsPDF({unit:'px', format:'a4'});
    doc.addImage(img, 'JPEG', 20, 20);
    doc.save('NOME-DO-PDF.pdf');
    //Retorna ao CSS normal
    $('#toda').width(cache_width);
  }
});
}
    
asked by anonymous 11.10.2018 / 19:26

0 answers