0

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.

Sivakesav
  • 31
  • 8

1 Answers1

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