title: How do I get domPDF to display my codeigniter view correctly
body: <p>I feel there is a small step that I am missing that apparently everyone on the other related questions understands.</p>
  
  <p>I have created a simple <strong>CI 2</strong> view, controller and model, shown below:</p>
  
  <p>I have installed <strong>dompdf</strong> into the helpers folder like so:</p>
  
  <pre><code>applications/helpers/dompdf
  
  applications/helpers/dompdf/dompdf_help.php
  </code></pre>
  
  <p>What I want to happen is when user clicks the submit button on the view page, send form data to the db, then get a pdf of that filled in form.</p>
  
  <p>Between getting underdefined var errors or nothing at all, except for the data going to db, I can't see what I am missing.</p>
  
  <p>Could some please guide me?  What am I not getting here?</p>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;test pdf&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
  &lt;?php // Change the css classes to suit your needs    
  
  $attributes = array('class' =&gt; '', 'id' =&gt; '');
  echo form_open('quicksubmit', $attributes); ?&gt;
  
  &lt;p&gt;
          &lt;label for="title"&gt;Title &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
          &lt;?php echo form_error('title'); ?&gt;
  
          &lt;?php // Change the values in this array to populate your dropdown as required ?&gt;
          &lt;?php $options = array(
                      ''  =&gt; 'Please Select',
                      'Mrs'    =&gt; 'Mrs',
                      'Miss'    =&gt; 'Miss',
                      'Ms'    =&gt; 'Ms',
                      'Mr'    =&gt; 'Mr',
                    ); ?&gt;
  
          &lt;br /&gt;&lt;?php echo form_dropdown('title', $options, set_value('title'))?&gt;
  &lt;/p&gt;                                             
  
  &lt;p&gt;
          &lt;label for="first_name"&gt;First Name&lt;/label&gt;
          &lt;?php echo form_error('first_name'); ?&gt;
          &lt;br /&gt;&lt;input id="first_name" type="text" name="first_name" maxlength="100" value="&lt;?php echo set_value('first_name'); ?&gt;"  /&gt;
  &lt;/p&gt;
  
  &lt;p&gt;
          &lt;label for="last_name"&gt;Last Name &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt;
          &lt;?php echo form_error('last_name'); ?&gt;
          &lt;br /&gt;&lt;input id="last_name" type="text" name="last_name" maxlength="100" value="&lt;?php echo set_value('last_name'); ?&gt;"  /&gt;
  &lt;/p&gt;
  
  &lt;p&gt;
          &lt;label for="branch"&gt;Branch&lt;/label&gt;
          &lt;?php echo form_error('branch'); ?&gt;
  
          &lt;?php // Change the values in this array to populate your dropdown as required ?&gt;
          &lt;?php $options = array(
                      ''  =&gt; 'Please Select',
                      'Branch 1'    =&gt; 'Branch One',
                      'Branch 2'    =&gt; 'Branch Two',
                    ); ?&gt;
  
          &lt;br /&gt;&lt;?php echo form_dropdown('branch', $options, set_value('branch'))?&gt;
  &lt;/p&gt;                                             
  
  &lt;p&gt;
          &lt;label for="zip"&gt;Zip&lt;/label&gt;
          &lt;?php echo form_error('zip'); ?&gt;
          &lt;br /&gt;&lt;input id="zip" type="text" name="zip" maxlength="7" value="&lt;?php echo set_value('zip'); ?&gt;"  /&gt;
  &lt;/p&gt;
  
  
  &lt;p&gt;
          &lt;?php echo form_submit( 'submit', 'Submit'); ?&gt;
  &lt;/p&gt;
  
  &lt;?php echo form_close(); ?&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>&lt;?php
  
  class Quicksubmit extends CI_Controller {
  
      function __construct()
      {
          parent::__construct();
          $this-&gt;load-&gt;library('form_validation');
          $this-&gt;load-&gt;database();
          $this-&gt;load-&gt;helper('form');
          $this-&gt;load-&gt;helper('url');
          $this-&gt;load-&gt;model('quicksubmit_model');
      }   
      function index()
      {           
          $this-&gt;form_validation-&gt;set_rules('title', 'Title', 'required|trim|xss_clean|max_length[50]');          
          $this-&gt;form_validation-&gt;set_rules('first_name', 'First Name', 'trim|xss_clean|max_length[100]');            
          $this-&gt;form_validation-&gt;set_rules('last_name', 'Last Name', 'required|trim|xss_clean|max_length[100]');         
          $this-&gt;form_validation-&gt;set_rules('branch', 'Branch', 'trim|xss_clean|max_length[100]');            
          $this-&gt;form_validation-&gt;set_rules('zip', 'Zip', 'trim|xss_clean|is_numeric|max_length[7]');
  
          $this-&gt;form_validation-&gt;set_error_delimiters('&lt;br /&gt;&lt;span class="error"&gt;', '&lt;/span&gt;');
  
          if ($this-&gt;form_validation-&gt;run() == FALSE) // validation hasn't been passed
          {
              $this-&gt;load-&gt;view('quicksubmit_view');
          }
          else // passed validation proceed to post success logic
          {
              // build array for the model
                      $this-&gt;pdf($output);
  
                          $form_data = array(
                                      'title' =&gt; set_value('title'),
                                      'first_name' =&gt; set_value('first_name'),
                                      'last_name' =&gt; set_value('last_name'),
                                      'branch' =&gt; set_value('branch'),
                                      'zip' =&gt; set_value('zip')
                                      );
  
              // run insert model to write data to db
  
              if ($this-&gt;quicksubmit_model-&gt;SaveForm($form_data) == TRUE) // the information has therefore been successfully saved in the db
              {
                  redirect('quicksubmit/success');   // or whatever logic needs to occur
              }
              else
              {
              echo 'An error occurred saving your information. Please try again later';
              // Or whatever error handling is necessary
              }
          }
      }
      function success()
      {
              redirect(base_url(),'refresh');     
              /*echo 'this form has been successfully submitted with all validation being passed. All messages or logic here. Please note
              sessions have not been used and would need to be added in to suit your app';*/
      }
          function pdf()
              {
                   $this-&gt;load-&gt;helper(array('dompdf', 'file'));
                   // page info here, db calls, etc.     
                   $html = $this-&gt;load-&gt;view('quicksubmit_view', $data, true);
                   pdf_create($html, 'filename');
                   /*or
                   $data = pdf_create($html, '', false);
                   write_file('name', $data);*/
                   //if you want to write it to disk and/or send it as an attachment    
              }
  }
  ?&gt;
  </code></pre>
  
  <p><strong>Model</strong></p>
  
  <pre><code>&lt;?php
  
  class Quicksubmit_model extends CI_Model {
  
      function __construct()
      {
          parent::__construct();
      }
  
      // --------------------------------------------------------------------
  
        /** 
         * function SaveForm()
         *
         * insert form data
         * @param $form_data - array
         * @return Bool - TRUE or FALSE
         */
  
      function SaveForm($form_data)
      {
          $this-&gt;db-&gt;insert('quicksubmit', $form_data);
  
          if ($this-&gt;db-&gt;affected_rows() == '1')
          {
              return TRUE;
          }
  
          return FALSE;
      }
  }
  ?&gt;
  </code></pre>
  
  <p><strong>dompdf_help.php file</strong></p>
  
  <pre><code>&lt;?php if (!defined('BASEPATH')) exit('No direct script access allowed');
  
  function pdf_create($html, $filename='', $stream=TRUE) 
  {
      require_once("dompdf/dompdf_config.inc.php");
  
          $dompdf = new DOMPDF();
          $dompdf-&gt;load_html($html);
          $dompdf-&gt;render();
          if ($stream) {
              $dompdf-&gt;stream($filename.".pdf");
          } else {
              return $dompdf-&gt;output();
          }
  }
  ?&gt;
  </code></pre>