166
rated 0 times
[
170]
[
4]
/ answers: 1 / hits: 8285
/ 4 Years ago, thu, september 3, 2020, 12:00:00
I imported jsPDF library and tried to export to PDF but I am getting JavaScript error jsPDF is not defined.
I tried other similar posts and it didn't work for me.
I got the fiddle here https://jsfiddle.net/aybhvf8e/1/
<script type="text/javascript" src="https://unpkg.com/jspdf@latest/dist/jspdf.umd.min.js"></script>
$( document ).ready(function() {
var doc = new jsPDF();
var specialElementHandlers = {
'#editor': function (element, renderer) {
return true;
}
};
})
$('#cmd').click(function () {
doc.fromHTML($('#content').html(), 15, 15, {
'width': 170,
'elementHandlers': specialElementHandlers
});
doc.save('sample-file.pdf');
});
<div id="content">
<h3>Hello, this is a H3 tag</h3>
<p>A paragraph</p>
</div>
<div id="editor"></div>
<button id="cmd">generate PDF</button>
More From » jspdf