title: Create PDF from specific div
body: <p>Good afternoon!</p>
  
  <p>I need to generate a PDF from a HTML page, but from a specific div </p>
  
  <pre><code>&lt;div id="canvas"&gt;
     all content is here
  &lt;/div&gt;
  </code></pre>
  
  <p>I have this function as a plugin in CodeIgniter, using mPDF</p>
  
  <pre><code>function pdf($html, $filename=null)
  {
      require_once("mpdf_lib/mpdf.php");
  
      $mpdf = new mPDF();
      $mpdf-&gt;WriteHTML($html);
  
      if($filename == null){
          $filename = date("Y-m-d").'_test.pdf';
      }
  
      $mpdf-&gt;Output($filename, 'I');
  }
  </code></pre>
  
  <p>I just need to know how I can get the html content from that specific div to pass as a parameter in <code>pdf ($html)</code> function.</p>
  
  <p>I found many examples but pratically all of them use 'static' html code.</p>
  
  <p>Thanks in advance!</p>