title: TCPDF convert inline SVG with html into PDF
body: <p>I am using TCPDF to convert html into PDF. </p>
  
  <pre><code>    $pdf = new TCPDF();
      $pdf-&gt;SetPrintHeader(false);
      $pdf-&gt;SetPrintFooter(false);
      $pdf-&gt;AddPage();       
  
      $html  = '&lt;div&gt;Some random html &lt;/div&gt;';        
      $pdf-&gt;writeHTML($html, true, false, true, false, '');
      $pdf-&gt;Output('/pdf/output.pdf','F');
  </code></pre>
  
  <p>It works like a charm.</p>
  
  <p>But I have a case when (Dynamic) html has SVG inline code also. So I need to convert this html which has SVG into PDF. But it does not work. Below is my code.</p>
  
  <pre><code>    $pdf = new TCPDF();
      $pdf-&gt;SetPrintHeader(false);
      $pdf-&gt;SetPrintFooter(false);
      $pdf-&gt;AddPage();       
  
      $html  = '&lt;div&gt;Some random html &lt;div style="width: 100px;"&gt;&lt;svg viewBox="10 0 80 80"&gt;
      &lt;ellipse cx="240" cy="100" rx="220" ry="30" style="fill:purple" /&gt;
      &lt;ellipse cx="220" cy="70" rx="190" ry="20" style="fill:lime" /&gt;
      &lt;ellipse cx="210" cy="45" rx="170" ry="15" style="fill:yellow" /&gt;
      Sorry, your browser does not support inline SVG. 
      &lt;/svg&gt;&lt;/div&gt; &lt;/div&gt;';        
      $pdf-&gt;writeHTML($html, true, false, true, false, '');
      $pdf-&gt;Output('/pdf/output.pdf','F');
  </code></pre>
  
  <p>So in this case the generated PDF has all the html printed in pdf but in place of SVG it says "Sorry, your browser does not support inline SVG".</p>
  
  <p>Is there any possible way to generate PDF from html containing SVG?</p>
  
  <p>Update I found <a href="http://www.pdfy.net/" rel="nofollow">http://www.pdfy.net/</a>  this website can convert html based svg into PDF. Any idea how they are doing it?</p>
  
  <p><strong>EDIT 1:</strong></p>
  
  <p>Okay Now I found that <a href="http://www.mpdf1.com/" rel="nofollow">mPDF</a> have supports for inline SVG. And it has really great support for it. <strong>But</strong>   mPDF have it's own problem of very less support for basic css. For Eg. Position absolute, float are not supported very well. </p>
  
  <p>So again I am back with the same problem with additional requirement. A library which supports conversion of html with inline svg to PDF and it also supports all basic CSS.</p>