title: Node.js - print on Server (yes, with a hardware printer on Win7 64-Bit)
body: <p>I've written a software using node.js and now I'am in need of the posssibility to use a usb printer. Like telling via client to print something out on a printer which is connected per usb to the node.js-server. I also wondered if I can execute an exe by node.js, shellexecute style.
  I've searched enough to justify this question.</p>
  
  <p>I appreciate any hint.</p>
  
  <p>I've found a solution ... not exactly what I wished for, but here an example:</p>
  
  <pre><code>var exec = require('child_process').exec;
  var Data = '';
  for (var i=0; i&lt;10; i++){Data+=i+' '}
  exec('printit.bat '+Data,
      function (error, stdout, stderr) {
          console.log('stdout: ' + stdout);
          console.log('stderr: ' + stderr);
          if (error !== null) {
              console.log('exec error: ' + error);
          }
      });
  </code></pre>
  
  <p>I execute a bat file in the root of my server.js file with given parameters (here just a count from 0 to 9, therefore 10 parameters to a bat file) so I can simply handle it there or even use an executable.</p>
  
  <p>There is a command in windows, called print. By using this command, like
   print /d:\networkprinterpath\printer1 c:\filetoprint.txt
  In my case, I use a special printer for receipts - a thermo printer. Those printers have a function, that cuts the paper. To add this function to the print, you have to add the special hexcode to the end of the file.
  As example my printer is an Epson TM-88 IV and to the end of file, I had success with the hex code 1D 56 42 FF. That should be appliable on ever TM-88 printer.</p>