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…
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…
Did you happen to see this one?
https://inductiveautomation.com/forum/viewtopic.php?p=35268#p35268
[quote=“JordanCClark”]Did you happen to see this one?
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.
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=“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.
So I can say to my boss, if the barcode printer with ethernet port is used, then I can print barcode labels from Ignition?
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.
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.
Just wondering if you ever got around to attempting this? We have huge value here at our facility if we could pull this off
Don't have my full code in front of me but this may help:
Note that I no longer recommend the python socket module in jython due to poor timing and ambiguous non-ASCII encodings. Use java.net or java.nio equivalents.
Finally made it back to my desk. Here’s a chopped down version of what I use.
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
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
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.
Indeed. Though I haven’t seen the DataOutputStream used like that. I usually use a PrintWriter.
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.
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.
How did you get the Zebra API installed under ignition?
Never mind I figured it out.
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.
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
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
[quote=“JordanCClark, post:11, topic:8957”]
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"