First configure jsPDF js file in script tag. This generatePDF function can then be called from anywhere in your code If you want a client-side solution to generate PDF documents, JavaScript is the easiest way to convert HTML to PDF. There are various J