The event name is “onrendered” The canvas object will be provided to the calback function. (Our captured screenshot) We’ll use “toDataURL” function to retrieve the screenshot We’ll specifiy the image type as “image/png” Next, we’ll create a jsPDF object as usual And we’ll use “addImage” to add the screenshot to the jsPDF object with 20px margin. And the final step is the save the PDF file. Success! It’s also possible if you only need to capture some part of the HTML page or some element Just pass the needed element instead of the entire body in the html2canvas I’ll pass our “testDiv” this time You’ll see that the header and download link are not included in the PDF file. Please noted that the html2canvas can’t capture any that are hotlink or not hosted in the same url of your site.
Thank you for watching! Subscribe us for more tutorial!.