Skip to content

Instantly share code, notes, and snippets.

@theodorocaliari
Created March 5, 2020 19:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save theodorocaliari/c832d6c28da8e4397371d4528c8bee7f to your computer and use it in GitHub Desktop.
Save theodorocaliari/c832d6c28da8e4397371d4528c8bee7f to your computer and use it in GitHub Desktop.
HTML2CANVAS
<script src="~/js/html2canvas.min.js"></script>
<script type="text/javascript">
function html2canvasPrint() {
html2canvas(
document.body,
{
backgroundColor: '#ffffff',
useCORS: true,
optimized: true,
allowTaint: 0,
foreignObjectRendering: true,
})
.then(canvas => {
var img = { token: canvas.toDataURL("image/png") };
var windowPrint = window.open("", "Dashboard");
windowPrint.document.write('<img src="' + img.token + '"/>');
j(windowPrint.document).ready(function () {
windowPrint.print();
//windowPrint.document.appendChild(canvas).print();
});
});
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment