Downloading php page as pdf in Codeigniter not working using JavaScript
one text
I have a Codeigniter website, in it which has a view page and its values are coming from database. I want to download the page as pdf, i tried tcpdf and dompdf, but the issue is css and JavaScript is not working im these libraries. So i tried using jspdf like below:
<button id="cmd">generate PDF</button>
<div class="container" id="content">
..........
</div>
<div id="editor"></div>
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');
});
Here the issue is, the pdf is getting downloaded but there is no data shown, a blank pdf is downloaded. Can anyone please tell me whats wrong here. Thanks in advance
Source