<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<title>AutoTable - Long Text Example</title>
</head>
<body>
<button id="export-btn" type="button">Export pdf</button>
</table>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.3/jspdf.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/2.3.1/jspdf.plugin.autotable.min.js"></script>
<script src="example.js"></script>
<!-- Some scripts to make the examples work nicely -->
<script>
document.getElementById('export-btn').onclick = function () {
exportPdf();
};
</script>
</body>
</html>
const headerTable = [
{ title: "USER", dataKey: "user" },
{ title: "KEY", dataKey: "key" },
{ title: "PHONE", dataKey: "phone" },
{ title: "ADDRESS", dataKey: "address" },
{ title: "RULE", dataKey: "rule" },
{ title: "SITUATION", dataKey: "situation" },
{ title: "DATE", dataKey: "date" },
{ title: "VALUE", dataKey: "value" }
];
var data = [];
for (var i = 1; i <= 10; i++) {
data.push({
user: "Leonardo Achiuasda Dasks",
key: "ABC-1234",
phone: '+12 12 12345-1234',
address: "Qui molestiae architecto cupiditate, ducimus P ullam, 1450",
rule: "molestiae architecto",
situation: "ducimus",
date: "17/04/2017 10:20",
value: "10.00"
});
}
function exportPdf() {
var doc = new jsPDF("l", 'cm', "a4");
doc.setFontType("normal");
doc.setFontSize(14);
doc.text(2, 4.1, "Molestiae architecto cupiditate");
doc.autoTable(headerTable, data, {
theme: 'striped',
styles: { overflow: 'linebreak'},
margin: { top: 5 },
});
doc.putTotalPages("{total_pages_count_string}")
doc.save('Test.pdf');
}