title: Use MPDF to convert .php file with variables to HTML
body: <p>After creating a page in php, I am using mpdf to create a pdf that appears like the page. The page is a receipt, so some of its entries are variables. The code for the page that turns the receipt page ('Receipt_Template_2.php') into a pdf is:</p>
  
  <pre><code>&lt;?php
  include("MPDF57/mpdf.php");
  
  ob_start();
  include "Receipt_Template_2.php"; 
  $template = ob_get_contents();
  ob_end_clean();
  
  $mpdf=new mPDF('','A4','','',32,25,27,25,16,13,'L'); 
  
  $mpdf-&gt;WriteHTML($template);
  
  $mpdf-&gt;Output('MyPDF.pdf', 'D');
  ?&gt;
  </code></pre>
  
  <p>However, the actual receipt template page has php variables printed onto it correctly. However, these variables are not printed onto the receipt (the fields are left blank). Thank you.</p>
  
  <p>I am mostly using session variables in my receipt template, such as below:</p>
  
  <pre><code>&lt;div id="apDiv1"&gt;&lt;img src="Receipt_Template_2.jpg" width="765" height="519"&gt;&lt;/div&gt;
  &lt;div id="apDiv2"&gt;
  &lt;p&gt;&lt;strong&gt;&lt;?php echo $_SESSION['firstName'] . ' ' . $_SESSION['lastName'];?&gt;&lt;/strong&gt;       &lt;/p&gt;
    &lt;p&gt;&lt;?php echo $_SESSION['address'];?&gt;&lt;/p&gt;
    &lt;p&gt;&lt;?php echo $_SESSION['city'] . ' ' . $_SESSION['province'];?&gt;&lt;/p&gt;
    &lt;p&gt;&lt;?php echo $_SESSION['postal'];?&gt;&lt;/p&gt;
    &lt;p&gt;&lt;?php echo $_SESSION['country'];?&gt;&lt;/p&gt;
  &lt;/div&gt;
  &lt;div id="apDiv3"&gt;&lt;?php echo $_SESSION['dateReceived'];?&gt;&lt;/div&gt;
  &lt;div id="apDiv4"&gt;&lt;?php echo date("Y-m-d");?&gt;&lt;/div&gt;
  &lt;div id="apDiv5"&gt;&lt;?php echo $_SESSION['locationIssued'];?&gt;&lt;/div&gt;
  &lt;div id="apDiv18"&gt;$&lt;?php echo $_SESSION['donationAmount'];?&gt;&lt;/div&gt;
  &lt;div id="apDiv6"&gt;&lt;?php echo $preReceiptNumber . $receiptNumber;?&gt;&lt;/div&gt;
  </code></pre>