How to print raw Intermec IPL commands from Javascript
Product JSPrintManager Published 07/30/2018 Updated 01/15/2019 Author Neodynamic
Overview
IPL (Intermec Programming Language) is one of the main printer languages from Intermec (now part of Honeywell International Inc.) that is supported by their printers which are widely used in POS (Point Of Sales or Point of Services) scenarios like retail, banking, hospitality, manufacturing, healthcare and more!
Intermec IPL commands are very simple and text plain! The main advantage of using raw Intermec IPL commands for printing instead of using the built-in browser javascript printing (window.print();) is that the printing performance will be way faster; a factor that is key in the aforementioned scenarios. No matter which Web Platform/Framework you use (ASP.NET, PHP, Django, Ruby On Rails (RoR), Express.js, AngularJS/SPA, etc.), you'll be able to use raw printing feature with the help of our JSPrintManager solution that was specially designed for this kind of printing needs.
In this walkthrough, you'll learn how to print raw IPL commands from Javascript directly to the client printer without displaying a print dialog at all. You'll be able to print Intermec IPL commands to the Default client printer as well as to any other installed printer at the client machine. This solution works with any popular browser like Chrome, Firefox, IE/Edge & Safari on Windows, Linux, Raspberry Pi and Mac systems!
The Intermec IPL commands that we'll use in this article will print out a simple shipping label that will look like this:
A Sample Shipping Label printed from Javascript and created by using Intermec IPL commands
Follow up these steps
- Be sure you install in your dev machine JSPrintManager (JSPM) (Available for Windows, Linux, Raspberry Pi & Mac)
This small app must be installed on each client that will print from your website! - By using your favorite Web Development IDE or Text Editor, create a new HTML file like index.html
Copy/paste the following snipped codes:HTML Code
<div style="text-align:center"> <h1>Print Intermec IPL commands from Javascript</h1> <hr /> <label class="checkbox"> <input type="checkbox" id="useDefaultPrinter" /> <strong>Print to Default printer</strong> </label> <p>or...</p> <div id="installedPrinters"> <label for="installedPrinterName">Select an installed Printer:</label> <select name="installedPrinterName" id="installedPrinterName"></select> </div> <br /><br /> <button type="button" onclick="print();">Print Now...</button> </div>
Script References
- Download JSPrintManager.js
- Copy all of these *.js files to the same folder where your html page is located and the add the following script references to your page.
<script src="JSPrintManager.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/bluebird/3.3.5/bluebird.min.js"></script> <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"></script>
Script Code
<script> //WebSocket settings JSPM.JSPrintManager.auto_reconnect = true; JSPM.JSPrintManager.start(); JSPM.JSPrintManager.WS.onStatusChanged = function () { if (jspmWSStatus()) { //get client installed printers JSPM.JSPrintManager.getPrinters().then(function (myPrinters) { var options = ''; for (var i = 0; i < myPrinters.length; i++) { options += '<option>' + myPrinters[i] + '</option>'; } $('#installedPrinterName').html(options); }); } }; //Check JSPM WebSocket status function jspmWSStatus() { if (JSPM.JSPrintManager.websocket_status == JSPM.WSStatus.Open) return true; else if (JSPM.JSPrintManager.websocket_status == JSPM.WSStatus.Closed) { alert('JSPrintManager (JSPM) is not installed or not running! Download JSPM Client App from https://neodynamic.com/downloads/jspm'); return false; } else if (JSPM.JSPrintManager.websocket_status == JSPM.WSStatus.Blocked) { alert('JSPM has blocked this website!'); return false; } } //Do printing... function print(o) { if (jspmWSStatus()) { //Create a ClientPrintJob var cpj = new JSPM.ClientPrintJob(); //Set Printer type (Refer to the help, there many of them!) if ($('#useDefaultPrinter').prop('checked')) { cpj.clientPrinter = new JSPM.DefaultPrinter(); } else { cpj.clientPrinter = new JSPM.InstalledPrinter($('#installedPrinterName').val()); } //Set content to print... //Create Intermec IPL commands for sample label var cmds = ''; cmds += "<STX><ESC>C0<ETX>"; cmds += "<STX><ESC>P<ETX>"; cmds += "<STX>E4;F4,DEMO 4<ETX>"; cmds += "<STX>L1;o11,447;f0;l1207;w4<ETX>"; cmds += "<STX>L2;o11,285;f0;l1207;w4<ETX>"; cmds += "<STX>W3;o11,0;f0;l1207;h802;w4<ETX>"; cmds += "<STX>B4;o658,650;f0;h102;w2;c0,0;i1;r1;d0,11<ETX>"; cmds += "<STX>I4;o658,752;f0;h1;w1;c20;r0;b0<ETX>"; cmds += "<STX>B5;o87,650;f0;h102;w2;c0,0;i1;r1;d0,11<ETX>"; cmds += "<STX>I5;o87,752;f0;h1;w1;c20;r0;b0<ETX>"; cmds += "<STX>H6;o34,183;f0;h1;w1;c22;r0;b0;d0,17<ETX>"; cmds += "<STX>H7;o35,143;f0;h1;w1;c21;r0;b0;d3,BASIS WT. 39-4838<ETX>"; cmds += "<STX>H8;o389,305;f0;h1;w1;c21;r0;b0;d3,ROLLS<ETX>"; cmds += "<STX>H9;o40,305;f0;h1;w1;c21;r0;b0;d3,ROLL WIDTH<ETX>"; cmds += "<STX>L10;o11,609;f0;l1207;w4<ETX>"; cmds += "<STX>H12;o1022,508;f0;h1;w1;c22;r0;b0;d0,7<ETX>"; cmds += "<STX>H13;o1022,467;f0;h1;w1;c21;r0;b0;d3,WEIGHT<ETX>"; cmds += "<STX>H14;o539,508;f0;h1;w1;c22;r0;b0;d0,11<ETX>"; cmds += "<STX>H15;o539,467;f0;h1;w1;c21;r0;b0;d3,LOCATION<ETX>"; cmds += "<STX>H16;o42,508;f0;h1;w1;c22;r0;b0;d0,15<ETX>"; cmds += "<STX>H17;o43,467;f0;h1;w1;c21;r0;b0;d3,CUSTOMER ORDER NUMBER<ETX>"; cmds += "<STX>H18;o840,346;f0;h1;w1;c22;r0;b0;d0,13<ETX>"; cmds += "<STX>H19;o840,305;f0;h1;w1;c21;r0;b0;d3,ORDER ITEM NUMBER<ETX>"; cmds += "<STX>H20;o389,346;f0;h1;w1;c22;r0;b0;d0,7<ETX>"; cmds += "<STX>H21;o34,346;f0;h1;w1;c22;r0;b0;d0,11<ETX>"; cmds += "<STX>H22;o747,183;f0;h1;w1;c22;r0;b0;d0,15<ETX>"; cmds += "<STX>H23;o743,143;f0;h1;w1;c21;r0;b0;d3,GRADE DESCRIPTION<ETX>"; cmds += "<STX>H24;o325,0;f0;h51;w34;c25;r0;b3;d3,SHIPPING LABEL<ETX>"; cmds += "<STX>R<ETX>"; cmds += "<STX><ESC>E4<CAN><ETX>"; cmds += "<STX><ESC>F4<LF>INTERMEC<ETX>"; cmds += "<STX><ESC>F5<LF>372181192<ETX>"; cmds += "<STX><ESC>F6<LF>38448379237<ETX>"; cmds += "<STX><ESC>F12<LF>230<ETX>"; cmds += "<STX><ESC>F14<LF>3839494<ETX>"; cmds += "<STX><ESC>F16<LF>372181192<ETX>"; cmds += "<STX><ESC>F18<LF>234-LOFT<ETX>"; cmds += "<STX><ESC>F20<LF>12<ETX>"; cmds += "<STX><ESC>F21<LF>338438<ETX>"; cmds += "<STX><ESC>F22<LF>A-PLUS QTY<ETX>"; cmds += "<STX><ETB><FF><ETX>"; cpj.printerCommands = cmds; //Send print job to printer! cpj.sendToClient(); } } </script>
- That's it! Run your website and test it. Click on Print Now... to print the Intermec IPL Commands without print dialog. You can print it to the Default client printer or you can get a list of the installed printers available at the client machine.
NOTE You can also print directly to any LPT Parallel Port, RS232 Serial Port or IP/Ethernet Printer although these scenarios have not been considered in this article for simplicity. For further details on those scenarios, please contact our tech support.