html2canvas and jspdf not render .svg image

Viewed 246

i am using jspdf and html2canvas for render my screen as pdf, it works fine but only issue is not render .svg image.

makePDF() {
    console.log('work')
    const options = {
        background: '#f1f1f1',
        scale: 1,
        pagebreak: {
            mode: 'avoid'
        }
    };
    html2canvas(document.querySelector(".capture"), options).then((canvas) => {
        var imgData = canvas.toDataURL('image/png');
        var imgWidth = 209;
        var pageHeight = 296;
        var imgHeight = canvas.height * imgWidth / canvas.width;
        var heightLeft = imgHeight;
        var doc = new jsPDF('p', 'mm', 'a4');
        var position = 5; // give some top padding to first page
        doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
        heightLeft -= pageHeight;
        while (heightLeft >= 0) {
            position += heightLeft - imgHeight; // top padding for other pages
            doc.addPage();
            doc.addImage(imgData, 'PNG', 0, position, imgWidth, imgHeight);
            heightLeft -= pageHeight;
        }
        doc.save('data.pdf');
    });
}
0 Answers
Related