<script src=" https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.2.61/jspdf.debug.js"></script>
<div id="test">
<table>
<tr>
<th>Header 1</th>
<th>Header 2</th>
<th>Header 3</th>
</tr>
<tr>
<td>Hello</td>
<td>I</td>
<td>am</td>
</tr>
<tr>
<td>a</td>
<td>table</td>
<td>.</td>
</tr>
</table>
<h1 style="text-align: center">
jsPDF
</h1>
<p>Though jsPDF can generate a pdf from html, it does not render CSS. Some styling is possible through special directives, though these are limited.</p>
<p>Also, text that is not aligned left seems to simply disapear.</p>
<p>One hack is to take pictures of the page using a library like HTMLtoCanvas, and then to paste those pictures onto the PDF. But then why use jsPDF at all?</p>
</div>
<a href="javascript:generatePDF()">Dowload PDF</a>
function generatePDF() {
var doc = new jsPDF('p', 'pt', 'a4');
var item = {
"Name" : "اسمي خضير",
"Age" : "22",
"Gender" : "Male"
};
var doc = new jsPDF();
var col = ["Details", "Values"];
var rows = [];
for(var key in item){
var temp = [key, item[key]];
rows.push(temp);
}
doc.autoTable(col, rows);
doc.save('Test.pdf');
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.