JSFiddle - React, Tailwind, and code Playground

by Pradeep Shankar

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.css">
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script>
<script src="http://mrrio.github.io/jsPDF/dist/jspdf.debug.js"></script>
<p>&nbsp;</p>
<div class="table-responsive" id="customers">
    <table class="table table-bordered table-striped table-condensed" id="tab_customers" >
       <thead>  <tr>
                                        <th >SL. No</th>
                                            

                                            <th>Feeder</th>
                                            

                                            <th>DTCName</th>
                                            

                                            <th>Date of hot spot identified</th>
                                            

                                            <th>PBR</th>
                                            

                                            <th>PBY</th>
                                            

                                            <th>PBB</th>
                                            

                                            <th>SBR</th>
                                            

                                            <th>SBY</th>
                                            

                                            <th>SBB</th>
                                            

                                            <th>SBN</th>
                                            

                                            <th>LT Kit</th>
                                            

                                            <th>GOS_r</th>
                                            

                                            <th>GOS_y</th>
                                            

                                            <th>GOS_b</th>
                         ...

CSS

.table-responsive {
    width: 100%;
    height: 300px;
    margin-bottom: 15px;
    overflow-y: scroll;
    -ms-overflow-style: -ms-autohiding-scrollbar;
    border: 1px solid #ddd;
  }

JavaScript

function demoFromHTML() {
    var pdf = new jsPDF('l', 'pt', 'a3');
    // source can be HTML-formatted string, or a reference
    // to an actual DOM element from which the text will be scraped.
    source = $('#customers').get(0);

    // we support special element handlers. Register them with jQuery-style 
    // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
    // There is no support for any other type of selectors 
    // (class, of compound) at this time.
    specialElementHandlers = {
        // element with id of "bypass" - jQuery style selector
        '#bypassme': function (element, renderer) {
            // true = "handled elsewhere, bypass text extraction"
            return true
        }
    };
    margins = {
        top: 10,
        bottom: 10,
        left: 10,
        width: 2000
    };
    
//    utf8_to_b64(source);
    
    // all coords and widths are in jsPDF instance's declared units
    // 'inches' in this case
    pdf.fromHTML(
    source, // HTML string or DOM elem ref.
    margins.left, // x coord
    margins.top, { // y coord
        'width': margins.width, // max width of content on PDF
        'elementHandlers': specialElementHandlers
    },

    function (dispose) {
        // dispose: object with X, Y of the last line add to the PDF 
        //          this allow the insertion of new lines after html
        pdf.save('Test.pdf');
    }, margins);
    
    
    function utf8_to_b64( str ) {
    return window.btoa(encodeURIComponent( str ));
}

function b64_to_utf8( str ) {
    return decodeURIComponent(window.atob( str ));
}
}