-
-
Save Keegan-y/1a4f8f3583f4229cb2f61662e26635af to your computer and use it in GitHub Desktop.
Create and send zpl file to 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 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