title: How to convert html table to pdf using pdfmake
body: <p>Am trying to convert my html table to pdf using pdfmake <a href="http://pdfmake.org/" rel="nofollow">http://pdfmake.org/</a> but i cant make it to how to use</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;?php $pdffile = md5(time()).'.pdf'; ?&gt;
  &lt;script src="jquery-1.7.2.min.js" type="text/ecmascript"&gt;&lt;/script&gt;
  &lt;script src="pdfmake.min.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script src="vfs_fonts.js" type="text/javascript"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
      $(document).ready(function(e) {
             var table = document.getElementById('table').outerHTML;
             var table = document.getElementById('table').innerHTML; // Same response with outerHTML
             var table = document.getElementById('table').value; // nothing is happening here
         docDefinition = {
              content: table   
         }
         pdfMake.createPdf(docDefinition).download('&lt;?php print $pdffile; ?&gt;');
      });
  &lt;/script&gt;
  &lt;?php
      $con = mysqli_connect('localhost','root','','db');
      if($con){
          echo 'connected'.'&lt;br/&gt;';
  
          $query = "SELECT * FROM user";
          $query_db = mysqli_query($con,$query);
          if(mysqli_num_rows($query_db) &gt; 0){
  ?&gt;
          &lt;table cellpadding="0" cellspacing="0" border="1" id="table"&gt;
              &lt;thead&gt;
                  &lt;tr&gt;
                      &lt;th&gt;ID&lt;/th&gt;
                      &lt;th&gt;Name&lt;/th&gt;
                      &lt;th&gt;Email&lt;/th&gt;
                  &lt;/tr&gt;
              &lt;/thead&gt;
              &lt;tbody&gt;
                  &lt;?php while($data = mysqli_fetch_array($query_db)): ?&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;?php print $data['user_id']; ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php print $data['username']; ?&gt;&lt;/td&gt;
                      &lt;td&gt;&lt;?php print $data['email']; ?&gt;&lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;?php endwhile; ?&gt;
              &lt;/tbody&gt;        
          &lt;/table&gt;
  &lt;?php           
  
          }else echo 'not data';
      }else echo 'error';
  ?&gt;
  &lt;/html&gt; 
  </code></pre>
  
  <p>From the code i have posted am getting html code not html table on my pdf file any way out sorry am not good at javascript?</p>