Skip to content

Instantly share code, notes, and snippets.

@sharoonthomas
Created April 29, 2016 14:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharoonthomas/30ebeb21b1d04011ef406bb7299024a9 to your computer and use it in GitHub Desktop.
Save sharoonthomas/30ebeb21b1d04011ef406bb7299024a9 to your computer and use it in GitHub Desktop.
Print barcodes on a zebra printer
import sys
# needs pip install zebra
from zebra import zebra
# Replace the string below.
# You can get valid names from zebra().getqueues()
printer_name = "Zebra_Technologies_ZTC_GC420d__EPL__2"
z = zebra(printer_name)
# Assumes a 1" W x 3" H label mounted at the center
# of a 4 x 6 label printer
z.setup(
direct_thermal=False,
label_height=(600, 12),
label_width=800
)
template = """^XA
^FO400,165^BY4,2,4^B3R,N,55,Y,N^FD%s^FS
^XZ"""
def print_barcode(barcode):
z.output(template % barcode)
if __name__ == '__main__':
print_barcode('F3')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment