Skip to content

Instantly share code, notes, and snippets.

@zlumer
Forked from andersonfreitas/html2canvas.js
Last active August 21, 2019 21:01
Show Gist options
  • Save zlumer/1b1e254fe6d8ecf243777debeeaaf8b9 to your computer and use it in GitHub Desktop.
Save zlumer/1b1e254fe6d8ecf243777debeeaaf8b9 to your computer and use it in GitHub Desktop.
Snippet to load html2canvas in the actual page
this.scriptObject=document.createElement('script');
this.scriptObject.type='text/javascript';
this.scriptObject.src='https://html2canvas.hertzen.com/dist/html2canvas.js';
var ssc = document.getElementsByTagName('script')[0];
ssc.parentNode.insertBefore(this.scriptObject, ssc);
function screenshot(elem)
{
return html2canvas(elem, {logging: true, profile: true, useCORS: true })
}
function appendScreenshot(elem)
{
screenshot(elem).then(x => document.body.append(x))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment