jsPDF is a javascript library that allow your page to easily generate PDF file dynamically
For example, We can choose an image and generate a PDF file when user click Download
Or draw some shapes
And utimately, generate PDF file from HTML tags
To use jsPDF, let's start with downloading the source code from "github.com/MrRio/jsPDF"
Once downloaded, you'll get a zip file.
There are lot of things included in the zip file but the only one thing we need is the "jsPDF.min.js" inside the "dist" folder
I have a skeleton html page for this example. Let's paste the jsPDF.min.js here next to it
Let's start with including the jsPDF to our page
Next, we'll create a PDF generator function that run when user click our download link
First, we need to create a jsPDF object
For this video, we'll add some text to the PDF file using text() method
We can specify the text location in (x,y) coordinate format
We can also add a new page using method addPage()
Let's add some text to the second page as well...
when we're done with the content, we'll use save method to specify our PDF file name and generate it
And finally, we'll add download link that will call our genPDF function when click
Now we're ready. Let's try it!
Thank you for watching, Our next video will show you how to generate PDF from your HTML page