Generating PDF with jQuery

Share Now

# Call This JS/jQuery Files

<script src=”https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.3.4/jspdf.debug.js”></script>
<script src=”https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js”></script>

# Now put this code in your main js file

//PRINT PDF
var pdfdoc = new jsPDF();
var specialElementHandlers = {
    '#ignoreContent': function(element, renderer) {
        return true;
    }
};

$(document).ready(function() {
    $("#gpdf").click(function() {
        pdfdoc.fromHTML($('#pdfBlock').html(), 10, 10, {
            'width': 110,
            'elementHandlers': specialElementHandlers
        });
        pdfdoc.save('result.pdf');
    });
});
Picture of Nahid Mahamud

Nahid Mahamud

Web Developer | Graphic Designer | WordPress & Woo-commerce Expert