Two tables and header with jspdf-autotable

Size
2,245 Kb
Views
74,888

How do I make an two tables and header with jspdf-autotable?

For stackoverflow question: http://stackoverflow.com/questions/33743540/problems-with-jspdf-and-autotable. What is a two tables and header with jspdf-autotable? How do you make a two tables and header with jspdf-autotable? This script and codes were developed by Simon Bengtsson on 07 December 2022, Wednesday.

Two tables and header with jspdf-autotable Previews

Two tables and header with jspdf-autotable - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Two tables and header with jspdf-autotable</title>
</head>
<body> <button onclick="generate()">Generate PDF</button>
<table id="basic-table" style="display: none;"> <thead> <tr> <th>ID</th> <th>First name</th> <th>Last name</th> <th>Email</th> <th>Country</th> <th>IP-address</th> </tr> </thead> <tbody> <tr> <td align="right">1</td> <td>Donna</td> <td>Moore</td> <td>[email protected]</td> <td>China</td> <td>211.56.242.221</td> </tr> <tr> <td align="right">2</td> <td>Janice</td> <td>Henry</td> <td>[email protected]</td> <td>Ukraine</td> <td>38.36.7.199</td> </tr> <tr> <td align="right">3</td> <td>Ruth</td> <td>Wells</td> <td>[email protected]</td> <td>Trinidad and Tobago</td> <td>19.162.133.184</td> </tr> <tr> <td align="right">4</td> <td>Jason</td> <td>Ray</td> <td>[email protected]</td> <td>Brazil</td> <td>10.68.11.42</td> </tr> <tr> <td align="right">5</td> <td>Jane</td> <td>Stephens</td> <td>[email protected]</td> <td>United States</td> <td>47.32.129.71</td> </tr> <tr> <td align="right">6</td> <td>Adam</td> <td>Nichols</td> <td>[email protected]</td> <td>Canada</td> <td>18.186.38.37</td> </tr> </tbody>
</table> <script src='https://cdn.rawgit.com/simonbengtsson/jsPDF/requirejs-fix-dist/dist/jspdf.debug.js'></script>
<script src='https://unpkg.com/[email protected]'></script> <script src="js/index.js"></script>
</body>
</html>

Two tables and header with jspdf-autotable - Script Codes JS Codes

function generate() { var doc = new jsPDF('p', 'pt'); var res = doc.autoTableHtmlToJson(document.getElementById("basic-table")); doc.autoTable(res.columns, res.data, {margin: {top: 80}}); var header = function(data) { doc.setFontSize(18); doc.setTextColor(40); doc.setFontStyle('normal'); //doc.addImage(headerImgData, 'JPEG', data.settings.margin.left, 20, 50, 50); doc.text("Testing Report", data.settings.margin.left, 50); }; var options = { beforePageContent: header, margin: { top: 80 }, startY: doc.autoTableEndPosY() + 20 }; doc.autoTable(res.columns, res.data, options); doc.save("table.pdf");
}
Two tables and header with jspdf-autotable - Script Codes
Two tables and header with jspdf-autotable - Script Codes
Home Page Home
Developer Simon Bengtsson
Username someatoms
Uploaded December 07, 2022
Rating 3
Size 2,245 Kb
Views 74,888
Do you need developer help for Two tables and header with jspdf-autotable?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Simon Bengtsson (someatoms) Script Codes
Create amazing video scripts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!