download pdf on button click code example
Example 1: javascript download file on click
You can trigger a download with the HTML5 download attribute.
<a href="path_to_file" download="proposed_file_name">Download</a>
Example 2: Pdf Download button
<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>
Example 3: Pdf Download button
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');
});