I wrote this code using JsPDF but doesn’t seems to work at all. What is should I use to make this work?

<!DOCTYPE html>
<html>
<head>
  <title>Generate PDF from Text</title>
</head>
<body>
  <h1>Generate PDF from Text</h1>
  
  <textarea id="textInput" rows="10" cols="50"></textarea>
  <br>
  <button id="downloadBtn">Download as PDF</button>
  
  <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js"></script>
  <script>
    document.getElementById("downloadBtn").addEventListener("click", function() {
      var text = document.getElementById("textInput").value;
      
      // Create a new jsPDF instance
      var doc = new jsPDF();
      
      // Set the font size and add the text to the PDF
      doc.setFontSize(12);
      doc.text(text, 10, 10);
      
      // Download the PDF file
      doc.save("my_pdf.pdf");
    });
  </script>
</body>
</html>

I am trying to acheive it so that the when I click the button, it allows me download a PDF file containing the things I wrote in the textarea.