Skip to content

Instantly share code, notes, and snippets.

@darklilium
Created May 4, 2016 16:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darklilium/7dff0ef6d1a031bfed8dff8a567ea7ce to your computer and use it in GitHub Desktop.
Save darklilium/7dff0ef6d1a031bfed8dff8a567ea7ce to your computer and use it in GitHub Desktop.
How to export data to PDF
Add the following files:
<script src="static/js/vendor/jspdf/jspdf.min.js"></script>
<script src="static/js/vendor/jspdf/jspdf.plugin.autotable.js"></script>
then make a fx with or w/o parameters, this one works like that just by example:
function exportToPDF(){
var columns = ["ID", "Name", "Country"];
var rows = [
[1, "Shaw", "Tanzania"],
[2, "Nelson", "Kazakhstan"],
[3, "Garcia", "Madagascar"],
];
// Only pt supported (not mm or in)
var doc = new jsPDF('p', 'pt');
doc.autoTable(columns, rows);
doc.save('table.pdf');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment