JSFiddle - React, Tailwind, and code Playground

by Vinayak_Pingale

HTML

<script src="https://raw.github.com/MrRio/jsPDF/master/dist/jspdf.min.js"></script>

         <body>
           <div id="content">
     <h3>Hello, this is a H3 tag</h3>

    <p>a pararaph</p>
         </div>
         <div id="editor"></div>
          <button id="cmd">generate PDF</button>
           </body>

CSS

body { padding: 40px }

JavaScript

$(function () {
    var doc = new jsPDF();
    var specialElementHandlers = {
        '#editor': function (element, renderer) {
            return true;
        }
    };

    $('#cmd').click(function () {
        doc.fromHTML($('#content').html(), 15, 15, {
            'width': 170,
                'elementHandlers': specialElementHandlers
        });
        doc.save('sample-file.pdf');
    });
});