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:
<divclass="rightpan"id='printablediv'><p>Print Content</p><inputtype='button'id="cmd"value="Download"class="button1 sbtbutton" /><div><divstyle="display: none;"id="editor"></div><scriptsrc="http://code.jquery.com/jquery-2.1.1.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.min.js"></script><scriptsrc="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"></script><script>var element = $("#printablediv"); // global variablevar getCanvas; // global variable
$("#cmd").on('click', function () {
html2canvas(element, {
onrendered: function (canvas) {
$("#editor").append(canvas);
getCanvas = canvas;
var img = canvas.toDataURL("image/png"),
doc = newjsPDF({
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"