Advertisement
EulisAires

viaseg js

Mar 13th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $(document).ready(function(){
  2.     $('#btnPDF').click(function() {
  3.       savePDF(document.querySelector('#geraPDF'));
  4.     });
  5. });
  6.  
  7. function savePDF(codigoHTML) {
  8.     html2canvas(document.getElementById("geraPDF"), {
  9.         onrendered: function(canvas){
  10.             var img = canvas.toDataURL('image/png', 'quality: 0.2');
  11.             var doc = new jsPDF('landscape', 'pt', 'a4');
  12.             doc.text(100,40,'Relatório das Vistorias');
  13.             doc.addImage(img, 'JPEG', 100, 100);
  14.             doc.save("Relatorio.pdf");
  15.         }
  16.     })
  17.  
  18. //     var doc = new jsPDF('landscape', 'pt', 'a4');
  19. //         doc.text(0,10,'numero');
  20. //         doc.setFontSize(9);
  21. //         doc.fromHTML($('#geraPDF').html(), 0, 0, {
  22. //             'width': 1000,
  23. //         });
  24. //         doc.save('sample-file.pdf');
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement