Last active
March 31, 2022 18:37
-
-
Save dantetesta/383cdd5a64f71ad9d2a18cd73e7d66ca to your computer and use it in GitHub Desktop.
This file contains 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 characters
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.3.3/html2canvas.min.js" integrity="sha512-adgfzougYIGhG3Tpb47fZLuMwaULLJQdujqOeWFoGc7vwFvBrFkhaPkJPId5swgdr122mghL/ysQk4oiabmRCQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> | |
<a id="btn-download" href="#" style="width:300px; text-align:center; display:block; font-size:20px; font-weight:bold; padding:15px; border:2px solid #fd5556; color:white; background:#fd5567"> | |
Fazer Download <i class="fa fa-download"></i></a> | |
<script> | |
jQuery("#btn-download").on('click', function () { | |
html2canvas(document.getElementById("print-area")).then(function (canvas) { | |
var anchorTag = document.createElement("a"); | |
document.body.appendChild(anchorTag); | |
//document.getElementById("previewImg").appendChild(canvas); | |
anchorTag.download = "nome-foto.jpg"; | |
anchorTag.href = canvas.toDataURL(); | |
anchorTag.target = '_blank'; | |
anchorTag.click(); | |
}); | |
}); | |
</script> | |
//NOMEAR A PRINT-AREA COM OS IDS CORRETOS = #print-area | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment