title: HTML to PDF (by javascript) how can I add css or table?
body: <p>In a project I have convert html file into pdf,than it's working fine.But this output not showing css design.Now I need a suggestion how can I add css design with this pdf file?</p>
  
  <p>Here the js function code :</p>
  
  <pre><code> $(function(){
           var doc = new jsPDF();
      var specialElementHandlers = {
          '#editor': function (element, renderer) {
              return true;
          }
      };
  
      $('#cmd').click(function () {
          doc.fromHTML($('#StudentInfoListTable').html(), 15, 15, {
              'width': 170,
                  'elementHandlers': specialElementHandlers
          });
          doc.save('sample-file.pdf');
      });
  </code></pre>
  
  <p>I took help from this project 
  <a href="https://github.com/MrRio/jsPDF" rel="nofollow noreferrer">https://github.com/MrRio/jsPDF</a></p>
  
  <p>This is my table looking 
  <img src="https://i.stack.imgur.com/C9ueQ.png" alt="enter image description here"></p>
  
  <p>This is the pdf output</p>
  
  <p><img src="https://i.stack.imgur.com/0VkgP.png" alt="enter image description here"></p>
  
  <p>I have tried to add a table </p>
  
  <pre><code>$('#cmd').click(function () {
  
          var table = tableToJson($('#StudentInfoListTable').get(0))
          var doc = new jsPDF('p', pt, 'a1', true);
          doc.cellInitialize();
          $.each(table, function (i, row){
              console.debug(row);
              $.each(row, function (j, cell){
                  doc.cell(10, 50,120, 50, cell, i);  // 2nd parameter=top margin,1st=left margin 3rd=row cell width 4th=Row height
              })
          })
  
  
          doc.save('sample-file.pdf');
      });
  </code></pre>
  
  <p>Here is the function </p>
  
  <pre><code>function tableToJson(table) {
      var data = [];
  
      // first row needs to be headers
      var headers = [];
      for (var i=0; i&lt;table.rows[0].cells.length; i++) {
          headers[i] = table.rows[0].cells[i].innerHTML.toLowerCase().replace(/ /gi,'');
      }
  
  
      // go through cells
      for (var i=0; i&lt;table.rows.length; i++) {
  
          var tableRow = table.rows[i];
          var rowData = {};
  
          for (var j=0; j&lt;tableRow.cells.length; j++) {
  
              rowData[ headers[j] ] = tableRow.cells[j].innerHTML;
  
          }
  
          data.push(rowData);
      }       
  
      return data;
  }
  </code></pre>
  
  <p>It make me cry after see this output !!</p>
  
  <p><img src="https://i.stack.imgur.com/t1RVc.png" alt="enter image description here"></p>
  
  <p>Any way to avoid this overlapping ?
  What is the best solution to add css in pdf? </p>