I wanted to convert my HTML page to a PDF file with a button click. After I click this "Download" button, I want the PDF to be automatically downloaded.
I tried this:
<button onclick="printFunction()">Download</button>
<script>
function printFunction() {
window.print();
}
</script>
But this can only generate a print page, which I need to save the PDF file manually.
I searched online and find a lot of answers that suggest we add a third-party plug-in. Is there an easier way to do that?