title: Dompdf convert canvas to pdf
body: <p>I'm trying to print a PDF with Dompdf filled with canvas elements. </p>
  
  <p>I can include and print png images with no problem but when trying to include a canvas and then convert it to a png it just won't display it in the exported PDF (no broken image, etc).</p>
  
  <p>What to do?  </p>
  
  <p>It is a Codeigniter project: </p>
  
  <p>Loading view in controller with Dompdf: </p>
  
  <pre><code>$this-&gt;load-&gt;library('pdf');
  $this-&gt;pdf-&gt;load_view('print_pdf', $data);
  $this-&gt;pdf-&gt;render();
  $this-&gt;pdf-&gt;stream("new_pdf_file.pdf");
  </code></pre>
  
  <p>View to be printed:</p>
  
  <pre><code>&lt;!doctype and so on..&gt;
  
  &lt;canvas id="myCanvas" width="578" height="200"&gt;&lt;/canvas&gt;
  
  &lt;script&gt;
     context.beginPath();
     context.moveTo(170, 80);
     context.bezierCurveTo(130, 100, 130, 150, 230, 150);
     context.closePath();
     context.lineWidth = 5;
     context.fillStyle = '#8ED6FF';
     context.fill();
     context.strokeStyle = '#0000ff';
     context.stroke();
  
     var canvas = document.getElementById("myCanvas");
     var img = canvas.toDataURL("image/png");
  
     $(document).ready(function() {
        $('&lt;img /&gt;', { 
           src: img
        });
        img.appendTo($('#testDiv'));
     });
  &lt;/script&gt;
  
  &lt;div id="testDiv"&gt;
  
  &lt;/div&gt;
  
  &lt;../html&gt;
  </code></pre>