Printing From Websites Part 3

Hello Programmers!  I’m back again with my series on printing from within websites.  This time I’m going to talk about using a client program to print. 

The downside is that, until recently, you had to write a client program for every OS you wanted to support with your website.  There is still the possibility that you may want to do that, but there are now several options to serve this need.

The benefits of using a client program are that most support multiple connectivity types like USB, Network, and Bluetooth.  They also are now supporting multiple OS's.  Some of these programs are self-contained and handle many aspects of printing including status checking and formatting.  Other programs provide a large amount of control to you as the web developer to handle the entire user experience.  Regardless of which you choose, your website coding to work with these apps is minimal.

Zebra has our own app to enable web-based printing called Browser Print.  This first release is for PC and USB connections, but stay tuned as we look into other operating systems, browsers, and connectivity types.  We are providing a JavaScript library and simple sample code to help enable your web apps.  It gives you full bi-directional control of the printer to get status and settings as well as print.

If your web app is primarily targeted towards mobile devices, Zebra has several partners with excellent apps that work with your webpages to allow your customers to print.  Sample code is easy to integrate. These apps are designed to take the heavy lifting of handeling the printer off your hands.

MobiPrint by Arrowhead

Centvia by Centrategy

Earlier Articles on this topic:

Robin West

Solution Architect

Zebra Technologies ISV

Pankaj Pandey

Hi Robin,

I am trying to Print a 2D Barcode Label with My GX430t Zebra Printer.

I am using JavaScript for Sending ZPL commands to the printer. Below is the JS Code:

var zpl = "^XA^FO50,100^BXN,10,200^FDYourTextHere^FS^XZ"

  var printWindow = window.open();

  printWindow.document.open('text/plain')

  printWindow.document.write(zpl);

  printWindow.document.close();

  printWindow.focus();

  printWindow.print();

  printWindow.close();

This doesn't print the Barcode but only prints Empty Label and Just one Text Page 1.

Can you help me if I am missing some configuration or code.

I am sending the same ZPL command from the Zebra Utility application and its printing the expected 2D Barcode.

I have also tried using the Generic/Text only driver but that too prints the ZPL commands as it is.

Thanks in advance.


Dirk van der Laarse

Hi Robin ( ​)

Thanks for all the information on printing on my Zebra printer from websites. I have a quick question:

I've followed all the steps outlined in the Browser Print User Guide, and successfully printed via the sample index.html page (USB connection and opening file on local machine). The guide is not very clear on going to the next step: printing from the opened html file on other machines on the network. My first guess is that I have to change the IP Address in the BrowserPrint-1.0.2.min file from local host to the IP of the machine with the Browser Print application installed. When I then try to print from another machine via the browser, I get the following error in the console: "The 'Access-Control-Allow-Origin' header contains the invalid value '127.0.0.1'. Origin 'null' is therefore not allowed access."

Can someone point me in the right direction to use the Browser Print application on a machine with Zebra printer connected via USB, and then print from the sample html page on another machine on the same network?

Kind regards,

Dirk


Noman Waseem

Hello Robin,

If I have more than one Zebra printer attached, is it possible to select which printer to send the commands to on the fly using Javascript?

Thanks!


Mauricio Guimaraes

Hi Robin,

I guess Browser Print is just what I need. My web app goal is to print labels from the browser to a USB connected Zebra printer.

My problem is, I need to send a list of values, organized in a table, with borders and all. But the sample code provided does not show how to do this, and I've just started working with Zebra printers.

Is there any way to use a label file created with ZebraDesigner and send my list of values as parameters to this label file?

Thanks in advance!


Anonymous (not verified)

Yes, ZebraDesigner does support variable fields.  Use the 'Export' function in the File menu to get the proper format.  You do have to set up the list of parameters properly (without the greater than and less than symbols) in order to tell the printer what to print:

^XA^XF<filename>^FN<field number 1>^FD<data 1>^FS^FN<field number 2>^FD<data 2>^FS^XZ

so a real print request would look like this:

^XA^XFE:NAMETAG.ZPL^FN11^FDRobin^FS^FN12^FDWest^FS^XZ