title: How to generate PDF from an html page
body: <p>I have a form which is displayed using my custom plugin. 
  Below given is code to display form using plugin:</p>
  
  <pre><code>$question = $wpdb-&gt;get_results("SELECT * FROM $table_name1 WHERE group_id=$id");
  $instruction = $question[0]-&gt;instructions;
  $html = "&lt;h2&gt;Instructions&lt;/h2&gt;&lt;p&gt;".$instruction."&lt;/p&gt;&lt;br&gt;&lt;button&gt;Download&lt;/button&gt;";
  $arr_size = sizeof($question);
  $html .= "&lt;form method='POST' action=''&gt;";
  for ($i=0; $i &lt; $arr_size ; $i++) { 
      $sid = $question[$i]-&gt;s_id;
      $html .= "&lt;b&gt;Question:&lt;/b&gt;&lt;i&gt;&lt;span&gt;".$question[$i]-&gt;questions."&lt;/span&gt;&lt;/i&gt;&lt;br&gt;";
      $answer = $wpdb-&gt;get_results("SELECT * FROM $table_name2 WHERE u_id=$userid AND s_id=$sid");
      $size = sizeof($answer);
      $option = $question[$i]-&gt;options;
      for ($j=1,$k=0; $j &lt;= $option; $j++,$k++) { 
          $html .= "&lt;input type='hidden' value='".$answer[$k]-&gt;a_id."' name='aid".$sid.$j."'&gt;";
          $html .= "&lt;textarea name='ans".$sid.$j."' id='ans".$sid.$j."'&gt;".$answer[$k]-&gt;answer."&lt;/textarea&gt;&lt;br&gt;";
      }
  }
  $html .= "&lt;input type='submit' value='submit' name='submit2'&gt;&lt;/form&gt;";
  return $html;
  </code></pre>
  
  <p>Previous values submitted will be their in the text boxes. I need to download the contents of the form when I click the download button not on form submission.</p>