Supporting label/barcode printers?

I have only limited knowledge in label printing. And within this limited scope I only know printers from Zebra. The good thing is that you don’t need any additional runtime libraries to get them running.

The ‘traditional Zebra way’ to print is through a dedicated and direct communication between (OpenMRS) server and printer. The server opens a socket to the printers IP address (therefore requiring server-to-printer TCP communication) and sends a bunch of ZPL commands. ZPL is the Zebra Printing/programming Language and is made of text-based commands to ‘render’ a certain print job (look here https://en.wikipedia.org/wiki/Zebra_(programming_language) https://en.wikipedia.org/wiki/Zebra_(programming_language) and on the Zebra page itself). Zebra offers a couple of additional tools for design/layout, but I don’t know them. A barcode within ZPL is also just a custom text-based command.

This is how the OpenMRS installation I know do their printing. It shouldn’t be too hard to include this server-side printing approach into the server-component of Bahmni/OpenMRS. But it didn’t look any further than this.

Additionally I’ve seen that newer printers from Zebra offer an HTTP interface. So instead of opening a socket to the printer you could speak HTTP to the embedded web server of each printer and send the ZPL commands over. Just as an evaluation I’ve written the following JavaScript lines which invokes a hard-coded print job on a specific printer (identified by its IP address) straight from the browser:

function wba_demo_print() { var zpl = “^XA^CI28^PW1300^MTT^FO080,40^AUN^FDtest name^FS^FO080,120^AUN^FDWBA100001^FS^FO080,190^ATN^FD20000101M^FS^FO680,40^FB520,1,0,R,0^AUN,140,110^FD123456^FS^FO780,160^ATN^BY4^BCN,150,N^F123456^FS^XZ”; print_this(zpl, “192.168.1.11”); }

function print_this(zpl, ip_addr) { var output = document.getElementById(“output”); var url = “http://”+ip_addr+"/pstprnt"; var method = “POST”; var async = true; var request = new XMLHttpRequest();

    request.onload = function () {
            var status = request.status; // HTTP response status, e.g., 200 for "200 OK"
            var data = request.responseText; // Returned data, e.g., an HTML document.
            output.innerHTML = "Status: " + status + "<br>" + data;
    }

    request.open(method, url, async);
    request.setRequestHeader("Content-Length", zpl.length);

    // Actually sends the request to the server.
    request.send(zpl);

}

However I’m not sure if such direct client/web browser to printer communication is the best idea (in terms of network topology, stability/reliability and potential abuse). Still: Assuming the WiFi allows client-to-client communication (aka client isolation disabled), it might the simplest thing to get it up and running in smallish installations with only very few printers.

christian