# Printing barcode to Zebra printer

**URL:** <https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957>\
**Category:** Ignition\
**Created:** [August 26, 2014, 2:53pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957 "2014-08-26T14:53:56Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [August 26, 2014, 2:53pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/1 "2014-08-26T14:53:56Z")

</div>

Is it possible to print to Zebra barcode code printer from Ignition?

I’ve searched the forum and all I found was few 2 years old topics…

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 26, 2014, 3:46pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/2 "2014-08-26T15:46:11Z")

</div>

Did you happen to see this one?

[https://inductiveautomation.com/forum/viewtopic.php?p=35268#p35268](https://inductiveautomation.com/forum/viewtopic.php?p=35268#p35268)

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [August 26, 2014, 5:29pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/3 "2014-08-26T17:29:47Z")

</div>

[quote=“JordanCClark”]Did you happen to see this one?

[https://inductiveautomation.com/forum/viewtopic.php?p=35268#p35268](https://inductiveautomation.com/forum/viewtopic.php?p=35268#p35268)[/quote]  
Yes, I’ve seen it…

The reason I’m asking is, there’s a potential project coming to our way in which the Zebra (or some other printer; I just hear that Zebra is most popular) printer and barcode labels are involved. I don’t know nothing about Zebra printers and barcode printing (I/we have no experience with this kind of printers, but I can learn… with some help 🙂 ), but I would very much like to use Ignition, if it’s possible. A quick look on the internet shows me that Zebra printers are mostly RS232, USB and Parallel port. Some of them can also have Ethernet (I don’t know which ones). At this point I also don’t know, which barcode printer we will/should use for this project.

I’m asking if we can print barcode labels with Ignition, so that we can say to the customer, Yes we can do it and we’ll do it with Ignition. If there are some kind of ‘special’ requirements to print barcode label from Ignition, I would like to know, so that I can be prepared, when/if it gets for real.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 26, 2014, 5:51pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/4 "2014-08-26T17:51:43Z")

</div>

It looks to be a straight ASCII over Ethernet application. I have a Zebra printer or two I can hang off the network to help out.

I’ve used Python Socket to run a marquee with no issues, others use the Java Socket library for Zebra printers with apparently good results.

---

<div class="post-metadata">

**Author:** ![zxcslo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/zxcslo/32/61610_2.png) [@zxcslo](https://forum.inductiveautomation.com/u/zxcslo)\
**Post date:** [August 26, 2014, 5:58pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/5 "2014-08-26T17:58:06Z")

</div>

[quote=“JordanCClark”]It looks to be a straight ASCII over Ethernet application. I have a Zebra printer or two I can hang off the network to help out.

I’ve used Python Socket to run a marquee with no issues, others use the Java Socket library for Zebra printers with apparently good results.[/quote]  
That’s much appreciated. ![:thumb_left:](https://us1.discourse-cdn.com/inductiveautomation/original/1X/e26afb081ddde6df016df6ee49159cf56aaca688.gif ":thumb\_left:")  
So I can say to my boss, if the barcode printer with ethernet port is used, then I can print barcode labels from Ignition?

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [August 26, 2014, 6:09pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/6 "2014-08-26T18:09:44Z")

</div>

Based on the other thread, I’d say yes. I’ll get a printer onto the network and play-- er… research and develop…

I should have a more definitive answer and/or methodology for you tomorrow. 😉

---

<div class="post-metadata">

**Author:** ![Malcolm](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/malcolm/32/5970_2.png) [@Malcolm](https://forum.inductiveautomation.com/u/Malcolm)\
**Post date:** [August 27, 2014, 11:55am UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/7 "2014-08-27T11:55:05Z")

</div>

I have worked with a similar Intermec Printer, I found it was acceptable to create a container on screen with the aspect ratio the same as label to use, then layout all the data as labels, text, values, barcodes as controls within the container and finally use ‘system.print.createPrintJob’ to create a print job to the printer to print the container.

This allowed a label image to be show in the ignition window of the exact label printed.

---

<div class="post-metadata">

**Author:** ![ntheuer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@ntheuer](https://forum.inductiveautomation.com/u/ntheuer)\
**Post date:** [April 13, 2021, 5:37pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/8 "2021-04-13T17:37:54Z")

</div>

Just wondering if you ever got around to attempting this? We have huge value here at our facility if we could pull this off

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 13, 2021, 5:56pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/9 "2021-04-13T17:56:06Z")

</div>

Don't have my full code in front of me but this may help:

> [@Send ZPL command to Zebra 170PAX4 via TCP/IP Socket](http://forum.inductiveautomation.com/t/send-zpl-command-to-zebra-170pax4-via-tcp-ip-socket/6003/22):
>
> Put something like this in a project script: import socket, sys def sendToZebra(payload): zebraAddr = ('10.50.100.250', 6101) try: s = socket.connect(zebraAddr) s.sendAll(payload) finally: s.close() Then call it from your button event like so: project.zebra.sendToZebra("^XA^WD^XZ") Not tested precisely as above, but I use this pattern at a customer site. NOTE: No driver required.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 13, 2021, 7:25pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/10 "2021-04-13T19:25:04Z")

</div>

Note that I no longer recommend the python socket module in jython due to poor timing and ambiguous non-ASCII encodings. Use [java.net](http://java.net) or java.nio equivalents.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 13, 2021, 7:44pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/11 "2021-04-13T19:44:40Z")

</div>

Finally made it back to my desk. Here’s a chopped down version of what I use.

```python
from java.net import Socket
from java.io import DataOutputStream

partnum = 'ABCBEFGH'
serialNum = '12345678'

strMessage100 = "^XA"  
strMessage110 = "^BY3,3,60^FT065,120,^BCN,N,N,N,N^FDP%s^FS" % partNum
strMessage111 = "^FT170,040^A0N,40,45^FD%s^FS" % partNum
strMessage112 = "^FT065,260,^BCN,N,N,N,N^FDS%s^FS" % serialNum
strMessage113 = "^FT170,170^A0N,40,45^FD%s^FS" % serialNum
strMessage199 = "^PQ1,0,1,Y^XZ"

strOut = strMessage100+strMessage110+strMessage111+strMessage112+strMessage113+strMessage199
  
  
printerIP='192.168.140.61'
port=9100
 
try:
  # Open Socket Connection
  clientSocket=Socket(printerIP,port)
  #Open data output stream
  outToPrinter=DataOutputStream(clientSocket.getOutputStream())
  #Send Data to Printer
  outToPrinter.write(strOut)
  #close data stream and socket
  outToPrinter.close();
  clientSocket.close();
except IOError:
  print "Error", row

```

---

<div class="post-metadata">

**Author:** ![ntheuer](https://avatars.discourse-cdn.com/v4/letter/n/ccd318/32.png) [@ntheuer](https://forum.inductiveautomation.com/u/ntheuer)\
**Post date:** [April 14, 2021, 5:09am UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/12 "2021-04-14T05:09:58Z")

</div>

Called the second shift team lead and asked him to check the zebra printer and voila, like magic. Thank you both! Shouldn’t have done this before bed though, cue brain overdrive mode.

@pturmel I will look into some Java solutions for a long term permanent solution to this problem, but this is a good start

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/d/2d03240e8b7200225ae96f19e4500a7ccde937e0.jpeg)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [April 14, 2021, 10:49am UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/13 "2021-04-14T10:49:05Z")

</div>

> [@ntheuer](#):
>
> I will look into some Java solutions for a long term permanent solution to this problem, but this is a good start

What Phil was saying was to use java libraries instead of the Jython ones. If you take a look at the imports at the top of the example I posted, you'll see we're using java libraries.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [April 14, 2021, 12:23pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/14 "2021-04-14T12:23:03Z")

</div>

Indeed. Though I haven’t seen the DataOutputStream used like that. I usually use a PrintWriter.

---

<div class="post-metadata">

**Author:** ![ryanjmclaughlin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ryanjmclaughlin/32/4318_2.png) [@ryanjmclaughlin](https://forum.inductiveautomation.com/u/ryanjmclaughlin)\
**Post date:** [April 14, 2021, 12:37pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/15 "2021-04-14T12:37:15Z")

</div>

The java code works fine, we have similar code today printing to the zebra printers.

Recently I have been exploring the Zebra API as well. I was able to easily install the jars into Ignition and do some printing with their native API. Its actually quite good.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/9/c/9cb3fed4d13d9e0faa0d9c4709e07d9fb36ddd26.png)

I’ll be switching over our current code to use their library in the future. If your using a newer zebra printer with LinkOS, the API code is even simpler and gives you a ton of options including full bi-directional status info.

I’d love to actually build a module around their API where the printers could be added as devices with tags for status and scripting functions for printing. But, with about 110% of my time consumed, that realistically won’t happen, but if some other module devs want to collaborate, let me know.

---

<div class="post-metadata">

**Author:** ![Mark.Randall](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Mark.Randall](https://forum.inductiveautomation.com/u/Mark.Randall)\
**Post date:** [July 15, 2021, 3:16pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/16 "2021-07-15T15:16:10Z")

</div>

How did you get the Zebra API installed under ignition?

---

<div class="post-metadata">

**Author:** ![Mark.Randall](https://avatars.discourse-cdn.com/v4/letter/m/53a042/32.png) [@Mark.Randall](https://forum.inductiveautomation.com/u/Mark.Randall)\
**Post date:** [July 15, 2021, 3:40pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/17 "2021-07-15T15:40:30Z")

</div>

Never mind I figured it out.

---

<div class="post-metadata">

**Author:** ![jmoniz](https://avatars.discourse-cdn.com/v4/letter/j/5daacb/32.png) [@jmoniz](https://forum.inductiveautomation.com/u/jmoniz)\
**Post date:** [July 15, 2021, 4:10pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/18 "2021-07-15T16:10:05Z")

</div>

This is what we use and works fine in a windows environment. Then we just assemble an EPL string and send it to the printer.

```auto
def CreatePrintJob(EPLString):

	from javax.print import PrintService
	from javax.print import PrintServiceLookup
	from javax.print import SimpleDoc
	from javax.print import DocFlavor
	from org.python.core.util import StringUtil
	from jarray import array
	
	#print "print triggered "+ event.source.name 
	
	pserv = PrintServiceLookup.lookupDefaultPrintService()
	if pserv == None:
		print "ERROR-01: no default print service"
	
	#data = array(EPLString,'b')
	data = StringUtil.toBytes(EPLString)
	#print data
	
	doc = SimpleDoc(data, DocFlavor.BYTE_ARRAY.AUTOSENSE, None)
	pserv.createPrintJob().print(doc, None)
	return
	
def LookupPrintServices():
	
	from javax.print import PrintService
	from javax.print import PrintServiceLookup
	from javax.print import SimpleDoc
	from javax.print import DocFlavor
	
	from jarray import array
	
	#print "print triggered "+ event.source.name 
	
	pservList = PrintServiceLookup.lookupPrintServices(None,None)
	if pservList == None:
		print "ERROR-01: no default print service"
	
	print pservList
	return
	
def CreateLabelPrintJob(EPLString,Name):

	from javax.print import PrintService
	from javax.print import PrintServiceLookup
	from javax.print import SimpleDoc
	from javax.print import DocFlavor
	from org.python.core.util import StringUtil

	from jarray import array
	
	pservList = PrintServiceLookup.lookupPrintServices(None,None)
	if pservList == None:
		print "ERROR-01: no default print service"
	
	printer = None
	for i in range(len(pservList)):
		s = str(pservList[i])
		r = s.find(Name)
		if r != -1:	printer = pservList[i]
	
	if printer == None:
		print "ERROR-01: no Label Printer"
		system.gui.messageBox("Printer " + Name + " not located, ensure correct printer is connected.","PRINTER NOT FOUND")
	else:
		#data = data = array(EPLString,'b')
		data = StringUtil.toBytes(EPLString)
		#print data
		
		doc = SimpleDoc(data, DocFlavor.BYTE_ARRAY.AUTOSENSE, None)
		printer.createPrintJob().print(doc, None)
		return

```

---

<div class="post-metadata">

**Author:** ![sagar.iparkar](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@sagar.iparkar](https://forum.inductiveautomation.com/u/sagar.iparkar)\
**Post date:** [September 2, 2022, 12:10pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/19 "2022-09-02T12:10:21Z")

</div>

Hi,  
Below code working in vision module. Can you please share code for Ignition Perspective module ( version 8.1.15 web browser running application print )?  
like:- Table dataset record print

---

<div class="post-metadata">

**Author:** ![sagar.iparkar](https://avatars.discourse-cdn.com/v4/letter/s/47e85d/32.png) [@sagar.iparkar](https://forum.inductiveautomation.com/u/sagar.iparkar)\
**Post date:** [September 2, 2022, 12:13pm UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/20 "2022-09-02T12:13:44Z")

</div>

[quote=“JordanCClark, post:11, topic:8957”]

```auto
strMessage111 = "^FT170,040^A0N,40,45^FD%s^FS" % partNum
strMessage112 = "^FT065,260,^BCN,N,N,N,N^FDS%s^FS" % serialNum
strMessage113 = "^FT170,170^A0N,40,45^FD%s^FS" % serialNum
strMessage199 = "^PQ1,0,1,Y^XZ"
Hi,
Can you please share which tools use for to design barcode print label?
e,g,:- auto tools generated code create : "^FT170,040^A0N,40,45^FD%s^FS"
```

[Next page](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957.md?page=2)
