When I save the div of svg to pdf it works fine but it does not show me the svg. Ive been struggling with this problem for 2 weeks is there anyone out there with a solution or any ideas or solutions
It should display like this
Instead it display like this when file is downloaded it does not show the svg
  document.getElementById("saveBtn").addEventListener("click", saveBtn);
                function saveBtn() {
                        html2canvas(document.getElementById("widget"), {
                            onrendered: function (canvas) {
                                var img = canvas.toDataURL("image/png");
                                var doc = new jsPDF();
                                doc.addImage(img, 'JPEG', 20, 20);
                                doc.save('test.pdf');
                            }
                        });
                    }
#canvas
{
display:none;
}
<div id="widget" class="collapsable open cell lg-1-3">Bars
<svg width="120" height="120" viewBox="0 0 120 120"
    xmlns="http://www.w3.org/2000/svg">
 
 <line x1="20" y1="100" x2="300" y2="100"
      stroke-width="10" stroke="green" />
   Yellow<line x1="20" y1="120" x2="300" y2="120"
      stroke-width="20" stroke="yellow" />
 
</svg>
<br><br>
<button id="saveBtn">Test<button>
 <canvas id="canvas">Test</canvas>

