JSFiddle - React, Tailwind, and code Playground

by Roberto Apasajja

HTML

<script src="https://dl.dropboxusercontent.com/u/11755646/jspdf.js"></script>
<div id="content">
     <h3>Hello, this is a H3 tag</h3>
     <p>Feedback form with screenshot This script allows you to create feedback forms which include a screenshot,
    created on the clients browser, along with the form.
    The screenshot is based on the DOM and as such may not be 100% accurate to the real
    representation as it does not make an actual screenshot, but builds the screenshot based on the
    information available on the page.</p>
      <ul style="font-size:33px">
        <li>Foo: <ul><li>Lorem Ipsum</li>
            <li><ol><li>Dolor Sit amen</li></ol></li></ul></li>
        <li>Lorem Ipsum</li>
        <li>Dolor Sit amen</li>
      </ul>
      <ol>
        <li>Bar:<ol><li>Lorem Ipsum</li>
            <li>Dolor Sit amen</li></ol></li>
        <li>Lorem Ipsum</li>
        <li>Dolor Sit amen</li>
      </ol>
      <ol>
        <li style="font-size:xx-large">Lorem Ipsum</li>
        <li>Dolor Sit amen</li>
        <li>Lorem Ipsum</li>
        <li>Dolor Sit amen</li>
      </ol>
      <p>Feedback form with screenshot This script allows you to create feedback forms which include a screenshot,
    created on the clients browser, along with the form.
    The screenshot is based on the DOM and as such may not be 100% accurate to the real
    representation as it does not make an actual screenshot, but builds the screenshot based on the
    information available on the page.</p>

</div>
<button id="cmd">generate PDF</button>

JavaScript

$(function () {
    $('#cmd').click(function () {
        var pdf = new jsPDF('p', 'pt', 'letter'),
        source = $('#content')[0],
        margins = {
            top: 40,
            bottom: 40,
            left: 40,
            right: 40,
            width: 522
        };
        
        pdf.fromHTML(
            source,
            margins.left,
            margins.top,
            {
            'width': margins.width 
            },
            function (dispose) {
                pdf.save('Test.pdf');
            },
            margins
       );
    });
});