title: Wordpress plugin HTML2PDF headers already sent
body: <p>I'm currently trying to use HTML2PDF (PHP Helper) to generate a HTML PDF with a Plugin. The Plugin is just a simple shortcode, to activate it. However, When i the function is activated (shortcode detected) I get an headers already sent message. I do understand that this means PHP has already set the header information.</p>
  
  <p>But how can i fix this? so the plugin will generate an PDF.</p>
  
  <p>Plugin code</p>
  
  <pre><code>require_once('html2pdf/html2pdf.class.php');
  
  add_shortcode('generate_pdf', 'pdf_saving');
  
  function pdf_saving()
  {
  
      $content_html = "&lt;h1&gt;Hello&lt;/h1&gt;";
      $html2pdf = new HTML2PDF('P', 'A4', 'en');
      $html2pdf-&gt;pdf-&gt;SetDisplayMode('fullpage');
      $html2pdf-&gt;writeHTML($content_html);
      // ob_clean(); I've also tried this.
      $html2pdf-&gt;Output('file.pdf');
  
  }
  </code></pre>
  
  <p>Error message,</p>
  
  <blockquote>
    <p>TCPDF ERROR: Some data has already been output, can't send PDF file</p>
  </blockquote>