How to handle SVG and canvas in pdfmake & html2pdfmake
<p>I am using <a href="https://github.com/ymkins/html2pdfmake" rel="nofollow noreferrer">html2pdfmake</a> to convert a div to pdf. My div contains tables and also contains some svg charts. But i am not getting the svg into the pdf. I tried converting it using base64 but is paste the base64 code into the pdf.</p>
<p>I converted my svg to base64 like :</p>
<pre><code>var html = d3.select('#idOfSVG').select(&quot;svg&quot;).attr(&quot;version&quot;, 1.1).attr(&quot;xmlns&quot;, &quot;http://www.w3.org/2000/svg&quot;).node().parentNode.innerHTML;
var imgsrc = 'data:image/svg+xml;base64,'+ btoa(html);
var base_image = new Image();
base_image.src = imgsrc;
canvas = document.createElement('canvas');
canvas.id = 'canvas'
document.body.appendChild(canvas);
canvas.width = 500;
canvas.height = 500;
canvas.getContext('2d').drawImage(base_image,0,0);
</code></pre>
<p>Then i added the same into the content.</p>
<p>Also when i used <code>ParseHtml(content,document.getElementById(&quot;myPDFDiv&quot;))</code></p>
<p>My div <code>myPDFDiv</code> gets deleted from the DOM.</p>
<p>Any help will be highly appreciated !!</p>