can we show html text in pdf javascript code example
Example 1: html to pdf javascript
var doc = new jsPDF();
var elementHandler = {
'#ignorePDF': function (element, renderer) {
return true;
}
};
var source = window.document.getElementsByTagName("body")[0];
doc.fromHTML(
source,
15,
15,
{
'width': 180,'elementHandlers': elementHandler
});
doc.output("dataurlnewwindow");
Example 2: print pdf javascript
// a javascript library for easily printing files from your page
// https://printjs.crabbly.com/
// add in the html head area
<script src="https://printjs-4de6.kxcdn.com/print.min.js"></script>
<script src="https://printjs-4de6.kxcdn.com/print.min.css"></script>
// add in your javaScript
function myPrint(){
printJS('myFile.pdf');
}
$('#printBtn').click(myPrint);