Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lutterlohdev/99451b67ce4a669fdd6cbb0dffd26704 to your computer and use it in GitHub Desktop.
Save lutterlohdev/99451b67ce4a669fdd6cbb0dffd26704 to your computer and use it in GitHub Desktop.
html2canvas usage
// npm install --save html2canvas
import html2canvas from 'html2canvas';
download = () => {
html2canvas(document.querySelector("#container")).then(canvas => {
const img = canvas.toDataURL('image/png')
let link = document.createElement('a');
link.href = img;
link.download = 'image.png';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment