I'm trying to add the html2canvas on my ASP.NET Core web site.
In documentation , they say to use:
npm install html2canvas
When I run this command, html2canvas
is installed on:
myproject/src/myproject/node_modules
When I try to use the html2canvas
methods, the following error occurs in the browser console:
html2canvas is not defined
So I manually added the html2canvas.js
file to my project and referenced it on the html
page. html2canvas is not defined
no longer appeared, but the page is not rendered correctly using the html2canvas
commands.
var element = document.getElementById("divPrint");
html2canvas(element).then(function(canvas) {
// Export the canvas to its data URI representation
var base64image = canvas.toDataURL("image/png");
// Open the image in a new window
window.open(base64image , "_blank");
});
What is the correct way to install? Via npm or just adding the file .js
?
Could anyone explain?