Export Html To Pdf Using JsPDF
Hi I want to Export html to pdf, I have use jsPDF all are working pdf also exporting but i want to get same html in pdf, html styles are not working what can I do for that can anyo
Solution 1:
<div class="rightpan" id='printablediv'>
<p>Print Content</p>
<input type='button' id="cmd" value="Download" class="button1 sbtbutton" />
<div>
<div style="display: none;" id="editor"></div>
<script src="http://code.jquery.com/jquery-2.1.1.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script>
<script>
    var element = $("#printablediv"); // global variable
var getCanvas; // global variable
$("#cmd").on('click', function () {
    html2canvas(element, {
        onrendered: function (canvas) {
            $("#editor").append(canvas);
            getCanvas = canvas;
            var img = canvas.toDataURL("image/png"),
            doc = new jsPDF({
                unit: 'px',
                format: 'a4'
            });
            doc.addImage(img, 'JPEG', 20, 20);
            doc.save('Vistordetails.pdf');
            form.width(cache_width);
        }
    });
});
Solution 2:
Late Answer!!
- Use Html2Canvas plugin to convert a div to canvas 
- next add the canvas image to JsPDF doc 
Post a Comment for "Export Html To Pdf Using JsPDF"