Created
May 4, 2021 10:55
-
-
Save sanjeevsiva17/c0eefadbaf75e90f37f53e79cd7f9d85 to your computer and use it in GitHub Desktop.
Create and send zpl file to printer
This file contains 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 os, sys | |
import subprocess | |
def printToPrnter(name, city): | |
data = "^XA" \ | |
"^FO200,30^ADN,30,20^FB400,3,0,C^FD"+name+"^FS" \ | |
"^FO200,80^ADN,30,20^FB400,3,0,C^FD"+city+"^FS" \ | |
"^XZ" | |
try: | |
f = open("code.zpl", "w") | |
f.write(data) | |
f.close() | |
except Exception as e: | |
return "Could not create zpl file :" + str(e) | |
try: | |
subprocess.call(['lp', '-d', 'Zebra_Technologies_ZTC_GC420t_', '-o', 'raw', 'code.zpl']) | |
except Exception as e: | |
return "Error calling printer :" + str(e) | |
os.remove("code.zpl") | |
return "Print Succesfull" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment