# 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:** 1\
**Showing post:** 26

<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:** [September 8, 2022, 10:44am UTC](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957/26 "2022-09-08T10:44:05Z")

</div>

No driver required.

> [@JordanCClark](#):
>
> Put it into a project script.

```python
def printLabel(partNum, serialNum, printerIP, port):
	from java.net import Socket
	from java.io import DataOutputStream

	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
	 
	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

```

Then call it from anywhere:

```python
pn = 'ABCDEFGH'
sn = '12345678'
printLabel(pn, sn, '192.168.140.61', 9100)
```

---

_[View the full topic](https://forum.inductiveautomation.com/t/printing-barcode-to-zebra-printer/8957)._
