Created
April 29, 2016 14:33
-
-
Save sharoonthomas/30ebeb21b1d04011ef406bb7299024a9 to your computer and use it in GitHub Desktop.
Print barcodes on a zebra printer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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