Download a div in a HTML page as pdf using javascript

http://stackoverflow.com/questions/17293135/download-a-div-in-a-html-page-as-pdf-using-javascript

HTML

<script src="//cdnjs.cloudflare.com/ajax/libs/jspdf/0.9.0rc1/jspdf.min.js"></script>
<table id="tableId">
  <thead>
    <tr>
      <th>HireDate</th>
      <th>Organization</th>
      <th>Skill</th>
      <th>Office</th>
      <th>DOB</th>
      <th>Department</th>
      <th>Status</th>
      <th>Recruiter</th>
      <th>since</th>
      <th>JobPortal</th>
      <th>Task</th>
      <th>Address</th>
      <th>SSN</th>
      <th>Title</th>
      <th>ContactInformation</th>
      <th>PersonId</th>
      <th>Name</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>null</td>
      <td> sadfas</td>
      <td>asd</td>
      <td>asdf</td>
      <td>asd</td>
      <td>asdfasde</td>
      <td>dfd</td>
      <td>asdf</td>
      <td>6</td>
      <td>dsfsdf</td>
      <td>0/15</td>
      <td>asdfasd</td>
      <td>564221111</td>
      <td>ddfd</td>
      <td>test@dff.com</td>
      <td>648218</td>
      <td>TEST asdf</td>
    </tr>
  </tbody>
</table>
<div id="editor"></div>
<button id="cmd">generate Excel</button>

JavaScript

$('#cmd').click(function() {
  var str = '<table><thead="color:red"><tr><th>HireDate</th><th>Organization</th><th>Skill</th><th>Office</th><th>DOB</th><th>Department</th><th>Status</th><th>Recruiter</th><th>since</th><th>JobPortal</th><th>Task</th><th>Address</th><th>SSN</th><th>Title</th><th>ContactInformation</th><th>PersonId</th><th>Name</th></tr></thead><tbody><tr><td>null</td><td> sadfas</td><td>asd</td><td>asdf</td><td>asd</td><td>asdfasde</td><td>dfd</td><td>asdf</td><td>6</td><td>dsfsdf</td><td>0/15</td><td>asdfasd</td><td>564221111</td><td>ddfd</td><td>test@dff.com</td><td>648218</td><td>TEST asdf</td></tr></tbody></table>';

  // 1, pass string directly
  window.open('data:application/vnd.ms-excel,' + encodeURIComponent(str));

  // 2, search by id, with extra proprties
  // https://bl.ocks.org/Flyer53/1de5a78de9c89850999c
});