Created
March 5, 2020 19:34
-
-
Save theodorocaliari/c832d6c28da8e4397371d4528c8bee7f to your computer and use it in GitHub Desktop.
Revisions
-
theodorocaliari created this gist
Mar 5, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ <a href="#" class="btn btn-primary btn2" onClick="html2canvasPrint()"><span class="icon-impressora"></span></a> This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,31 @@ <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>