I fetched the data from database, then I need to generate a pdf by clicking a hyperlink. This clicking event should be in JQuery. I don't have any idea to write the code.
Asked
Active
Viewed 723 times
0
-
Can you show us what you have tried ? – Prakash Thete Jul 01 '16 at 06:14
-
1You should check this, http://stackoverflow.com/questions/4490028/is-it-possible-to-generate-pdf-using-jquery – Samir Jul 01 '16 at 06:15
-
No, I didn't tried any thing. Just give the idea, how to do it – Sivakesav Jul 01 '16 at 06:18
1 Answers
0
Hi @Sivakesav Parikala you can create pdf at client side using the jsPDF plugin.
Below is the sample code for the same
HTML :
<button id="cmd">generate PDF</button>
JS :
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.2.61/jspdf.debug.js"></script>
$(document).ready(function(){
var doc = new jsPDF();
$('#cmd').click(function () {
doc.text(35, 25, "Praksh loves jsPDF");
doc.save('sample-file.pdf');
});
});
Please find the demo for the same JSFiddle : https://jsfiddle.net/Prakash_Thete/so2rxpzu/
For more details on the plugin please visit : https://parall.ax/products/jspdf

Prakash Thete
- 3,802
- 28
- 28