Print file via Raw Using Javascript - Javascript Global

Javascript examples for Global:encodeURIComponent

Description

Print file via Raw Using Javascript

Demo Code

ResultView the demo in separate window

<html>
   <head></head>
   <body> 
      <button id="print">Print file</button> 
      <script type="text/javascript">
    function printZpl(zpl) {/*  w  w  w.  ja va2s . c  o m*/
      var printWindow = window.open(`data:text/html,<html><body><pre>${zpl}</pre><script>print();<\/script></body></html>`);
      printWindow.focus();
    }
    var zpl = `asdfaasdfasdfasdfasdfasdfasdfasdf`;
document.getElementById("print")
.onclick = function() {
    printZpl(encodeURIComponent(zpl))
};

      </script>  
   </body>
</html>

Related Tutorials