title: Open page as pdf with DOMPDF
body: <p>I am currently working on a semi dynamic page where I use some GET functionality to personalize it. I also echo the date a couple of places. At the bottom of this page, I would like to have a button that gives the visitor the option to download/open this page as PDF. Without the header. I have integrated DOMPDF, but I simply cant get it to work properly and need some help. I have tried a couple of things found here on Stackoverflow, with no success.</p>
  
  <p>In basic, I need the whole page printed in the PDF, but it should not open when page is loaded. But triggered by the button. And then without the header (one spesific div). Is this possible?</p>
  
  <pre><code>&lt;?php
      require_once("dompdf/dompdf_config.inc.php");
  
      $html =
          '&lt;html&gt;&lt;body&gt;'.
          '&lt;p&gt;This is a test for '.
          '&lt;?php echo htmlentities(substr(urldecode($_SERVER["QUERY_STRING"]), 1)); ?&gt; &lt;/p&gt;'.
          '&lt;p&gt;Thank you for reading.&lt;/p&gt;'.
          '&lt;/body&gt;&lt;/html&gt;';
  
      $dompdf = new DOMPDF();
      $dompdf-&gt;load_html($html);
      $dompdf-&gt;render();
      $dompdf-&gt;stream("the_inquiry.pdf");
      return true;
      ?&gt;
  &lt;html&gt;
  &lt;body&gt;
  &lt;div class="shouldnotPrintToPDF"&gt;
  Content.
  &lt;/div&gt;
  &lt;div class="shouldPrintToPDF"&gt;
  Sensitive content.
  &lt;a href="the_inquiry.pdf"&gt;Open or save as PDF&lt;/a&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>This is basically our one page presentation. And contains a lot of text, so I will not present all of that here. But in this way, I have to write the page twice, in $html = as well as inside the actual  tag. And the PDF save/open option pops up right from the start, which it should not. I also wish to append the echo htmlentities part to the actual pdf-name.. is this possible? The PDF opens and contains what put into the $html = just fine. But not triggered by the link.</p>
  
  <p>Update:
  When i do exactly what you perform here, I get an error "The requested URL /inquiry.php&amp;pdf=1 was not found on this server." I have the page I am trying to print in pdf on root level, but the DOMPDF is in /dompdf.. I dont know if that has anything to do with it?</p>
  
  <p>Update:
  When i edited the link, i get all this information up in a new page, like below.</p>
  
  <pre><code>    [_parse_properties(margin:=1.2cm)(empty)_parse_properties]
  [_parse_sections[section[_parse_properties(display:=-dompdf-page)
  (counter-reset:=page)(empty)_parse_properties]#html#section]
  [section[_parse_properties(empty)_parse_properties]#empty#section]
  _parse_sections][_parse_sections[section[_parse_properties(display:=block)
  (empty)_parse_properties]#div##map##dt##isindex#section]
  [section[_parse_properties(empty)_parse_properties]#empty#section]
  _parse_sections][_parse_sections[section[_parse_properties(page-break
  -before:=avoid)(display:=block)(counter-increment:=page)
  (empty)_parse_properties]#body#section]
  [section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
  [_parse_sections[section[_parse_properties(display:=block)(margin:=1em 
  0)(empty)_parse_properties]#p##dl##multicol#section]
  [section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
  [_parse_sections[section[_parse_properties(display:=block)(margin-left:=40px)
  (empty)_parse_properties]#dd#section]
  [section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
  [_parse_sections[section[_parse_properties(display:=block)(margin:=1em 
  40px)(empty)_parse_properties]#blockquote#section]
  [section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
  [_parse_sections[section[_parse_properties(display:=block)(font-style:=italic)
  (empty)_parse_properties]#address#section]
  [section[_parse_properties(empty)_parse_properties]#empty#section]_parse_sections]
  [_parse_sections[section[_parse_properties(display:=block)(text-align:=center)
  (empty)_parse_properties]#center#section]
  </code></pre>
  
  <p>Do you have any idea what it might be caused by?</p>
  
  <p>Breakthrough:</p>
  
  <p>When I activated DOMPDF_DPI it actually opens as PDF, but now all of the text comes on first line of the second page of the PDF. Like, all the text comes out on top of each other. Also, when it opens the PDF, the ?&amp;pdf=1 are included in the htmlentities query string, which looks very messy since it is supposed to be a personalized page as well as the PDF.</p>