React JS pdf gerar a partir de html

// Rendering react as pdf is generally a pain,
// but there is a way around it using canvas.

// The idea is to convert : HTML -> Canvas -> PNG (or JPEG) -> PDF
// To achieve the above, you'll need :

// npm install --save html2canvas
// npm install jspdf --save
...
printDocument() {
    const input = document.getElementById('divToPrint');
    html2canvas(input)
      .then((canvas) => {
        const imgData = canvas.toDataURL('image/png');
        const pdf = new jsPDF();
        pdf.addImage(imgData, 'JPEG', 0, 0);
        // pdf.output('dataurlnewwindow');
        pdf.save("download.pdf");
      })
    ;
}
GutoTrosla