title: Creating PDF using TCPDF and a specific div as the content
body: <p>I am trying to create a receipt for a web application by turning the receipt from the HTML code into a PDF so that it can be downloaded upon completion of the application. I have tried to send the code to a PHP file by assigning the contents of the targeted div to a hidden input field within a form. Upon pressing the button at the end, the js function below is executed onclick, as well as the PHP file:</p>
  
  <pre><code>function print() {
      var elem = document.getElementById("receipt").innerHTML;
      document.getElementById("hiddenhtml").value = elem;
  }
  </code></pre>
  
  <p>Here is a rough outline of the form:</p>
  
  <pre><code>&lt;form method="post" action="htmlpdf.php" target="_blank"&gt;
      &lt;div id="receipt"&gt;
          ------- CONTENT THAT I WANT IN THE PDF ----------
      &lt;/div&gt;
      &lt;input type="submit" onclick="print()" value="Print"/&gt;
      &lt;input id="hiddenhtml" type="hidden" value=""/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Where hiddenhtml is a hidden input field. Upon pressing the print button, the contents of the receipt div are added to the value of the hidden input field. I then try to pass this value as follows:</p>
  
  <pre><code>$html = $_POST['hiddenhtml'];
  $pdf-&gt;writeHTML($html, true, false, true, false, '');
  </code></pre>
  
  <p>To use it in the writeHTML function. However, a blank PDF file is returned. I was wondering wether I can pass the contents of the targeted div as a parameter in the writeHTML method. The div has no external styling, and contains all compliant tags per the documentation.</p>