{"id":8012,"date":"2015-11-21T01:37:00","date_gmt":"2015-11-21T01:37:00","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/21\/how-to-export-the-html-tables-data-into-pdf-using-jspdf-open-source-projects-mrrio-jspdf\/"},"modified":"2022-08-30T15:03:04","modified_gmt":"2022-08-30T15:03:04","slug":"how-to-export-the-html-tables-data-into-pdf-using-jspdf-open-source-projects-mrrio-jspdf","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/21\/how-to-export-the-html-tables-data-into-pdf-using-jspdf-open-source-projects-mrrio-jspdf\/","title":{"rendered":"How to export the Html Tables data into PDF using Jspdf-open source projects MrRio\/jsPDF"},"content":{"rendered":"<p><img decoding=\"async\" src=\"http:\/\/www.gravatar.com\/avatar\/3a1b07b0a676f70686cffd916cddeccb?s=128&amp;d=identicon&amp;r=PG\" \/> <strong>lando<\/strong><\/p>\n<p>&#8220;How to properly use jsPDF library&#8221; might give you a little more of what you need. The table won&#8217;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.<\/p>\n<p>Another option would be to use screenshots of the HTML with HTML2Canvas or Casper.js.<\/p>\n<p><strong>EDIT<\/strong><\/p>\n<p>Here&#8217;s a basic example using the jspdf cell plugin. It uses jquery and the <code>tableToJson()<\/code> function from HTML Table to JSON.<\/p>\n<p>Be sure to include the Deflate lib (two js files) and <code>jspdf.plugin.cell.js<\/code>.<\/p>\n<pre><code>var table = tableToJson($('#table-id').get(0))\nvar doc = new jsPDF('p', 'pt', 'a4', true);\ndoc.cellInitialize();\n$.each(table, function (i, row){\n  $.each(row, function (j, cell){\n    doc.cell(10, 200, 100, 20, cell, i);\n  })\n})\ndoc.save()\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>lando &#8220;How to properly use jsPDF library&#8221; might give you a little more of what you need. The table won&#8217;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 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8012","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8012","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=8012"}],"version-history":[{"count":1,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8012\/revisions"}],"predecessor-version":[{"id":8698,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/8012\/revisions\/8698"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=8012"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=8012"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=8012"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}