I am using this piece of javascript to print out some html content:
function printHTML(htmlToPrint) {
var mywindow = window.open('', 'PRINT', 'height=400, width=600');
mywindow.document.write("<html><head><title>My Doc Title</title>");
mywindow.document.write("</head><body>");
mywindow.document.write(htmlToPrint);
mywindow.document.write("</body></html>");
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10*/
mywindow.print();
mywindow.close();
return true;
}
And this work absolutely fine.
It opens the print dialog and then you can either 'print' it or 'save it as pdf'.
What I'd like to do is to skip the print dialog and save (download) it as pdf sraight away at the end of my function. I found a lot of suggestions to use jsPDF library for this, but couldn't find any easy examples on how to use it in my case...
Any advise is highly appreciated :)