Last active
May 25, 2022 12:04
-
-
Save dantetesta/16996034ecd506ec5e48c805b69bbcea to your computer and use it in GitHub Desktop.
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 characters
| /*BY: ASK JARVIS + DANTE TESTA */ | |
| <script src="https://code.jquery.com/jquery-3.6.0.slim.js" integrity="sha256-HwWONEZrpuoh951cQD1ov2HUK5zA5DwJ1DNUXaM6FsY=" crossorigin="anonymous"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/0.4.1/html2canvas.js"></script> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.0.272/jspdf.debug.js"></script> | |
| /*COMPONENTE DE BOTÃO PARA CHAMAR O DOWNLOAD*/ | |
| <button id="btn-download">Download PDF</button> | |
| /*SCRIPT PARA GERAR O PRINT E SALVAR NO PDF*/ | |
| <script> | |
| document.getElementById("btn-download").addEventListener("click", function() { | |
| html2canvas(document.getElementById("content"), { | |
| onrendered: function(canvas) { | |
| var imgData = canvas.toDataURL("image/png"); | |
| var pdf = new jsPDF(); | |
| pdf.addImage(imgData, "PNG", 0, 0); | |
| pdf.save("download.pdf"); | |
| } | |
| }); | |
| }); | |
| </script> | |
| /*DEFINA A LARGURA DO DOCUMENTO A SER PRINTADO*/ | |
| <style> | |
| #content{ | |
| width:1000px; | |
| } | |
| </style> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment