0

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?

Mary
  • 231
  • 1
  • 3
  • 12
  • 2
    There is no magic browser method to print to PDF. – BenM Mar 14 '22 at 17:26
  • Does this answer your question? [Is it possible to save HTML page as PDF using JavaScript or jquery?](https://stackoverflow.com/questions/6896592/is-it-possible-to-save-html-page-as-pdf-using-javascript-or-jquery) – caramba Mar 14 '22 at 17:28

0 Answers0