How to export the Html Tables data into PDF using Jspdf-open source projects MrRio/jsPDF
lando
“How to properly use jsPDF library” might give you a little more of what you need. The table won’t render correctly (no css, per this answer), but you could do some parsing of the html table with jquery and manually style it yourself.
Another option would be to use screenshots of the HTML with HTML2Canvas or Casper.js.
EDIT
Here’s a basic example using the jspdf cell plugin. It uses jquery and the tableToJson()
function from HTML Table to JSON.
Be sure to include the Deflate lib (two js files) and jspdf.plugin.cell.js
.
var table = tableToJson($('#table-id').get(0))
var doc = new jsPDF('p', 'pt', 'a4', true);
doc.cellInitialize();
$.each(table, function (i, row){
$.each(row, function (j, cell){
doc.cell(10, 200, 100, 20, cell, i);
})
})
doc.save()