Advertisement
Guest User

Untitled

a guest
Dec 14th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.10 KB | None | 0 0
  1. ## in footer.php line 1
  2. <!-- Modal Print -->
  3. <div id="myModalPrint" class="modal fade" role="dialog">
  4.   <div class="modal-dialog modal-lg">
  5.  
  6.     <!-- Modal content-->
  7.     <div class="modal-content">
  8.       <div  class="modal-header">
  9.         <button type="button" class="close" data-dismiss="modal">&times;</button>
  10.         <h4 class="modal-title">Modal Print page</h4>
  11.           <div id="MHP">
  12.             <a class="btn btn-primary " onclick="getdataUrlPrint();">Print</a>
  13.             </div>
  14.       </div>
  15.       <div id="MBP" class="modal-body">
  16.        
  17.       </div>
  18.       <div class="modal-footer">
  19.         <button type="button" class="btn btn-default" data-dismiss="modal">Cansel</button>
  20.       </div>
  21.     </div>
  22.  
  23.   </div>
  24. </div>
  25.  
  26.  
  27.  
  28.  
  29. #-------------------------------------------------------------------
  30. ## last thing in footer.php :
  31.  
  32. <script>
  33. function ctrlP(){
  34.     html2canvas(document.querySelector("body")).then(canvas => {
  35.         canvas.id = 'canvasPrint';
  36.        
  37.         canvas.style.width  = '100%';
  38.         canvas.style.height  = "auto";
  39.         canvas.style.border  = "solid";
  40.  
  41.         $("#MBP").html(canvas);
  42.        
  43.        
  44.     });
  45. }
  46.     function getdataUrlPrint(){
  47.         printCanvas(document.getElementById('canvasPrint').toDataURL());
  48.     }
  49.     function printCanvas(dataUrl)  
  50. {  
  51.     var windowContent = '<!DOCTYPE html>';
  52.     windowContent += '<html>'
  53.     windowContent += '<head><title>PRINT</title></head>';
  54.     windowContent += '<body>'
  55.     windowContent += '<img src="' + dataUrl + '">';
  56.     windowContent += '</body>';
  57.     windowContent += '</html>';
  58.     var printWin = window.open('', '', 'width=' + screen.availWidth + ',height=' + screen.availHeight);
  59.     printWin.document.open();
  60.     printWin.document.write(windowContent);
  61.     printWin.document.close();
  62.     printWin.focus();
  63.     printWin.print();
  64.     printWin.close();
  65. }
  66.  
  67. #-------------------------------------------------------------------
  68. # download this script : https://html2canvas.hertzen.com/
  69. # after download, add to website like this :
  70. <script src="js/html2canvas.min.js"></script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement