File tree Expand file tree Collapse file tree 3 files changed +36
-0
lines changed
Expand file tree Collapse file tree 3 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ ![ LabelZoom Logo] ( https://www.labelzoom.net/assets/base/images/LabelZoom_Logo_f.svg )
12# python-zpl-utils
23A collection of Python scripts to improve the experience of owning a Zebra printer
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ # -*- coding: utf-8 -*-
3+
4+ """png-to-zpl.py: Uses the LabelZoom API to convert a PNG image to ZPL"""
5+
6+ import requests
7+
8+ image_path = 'LabelZoom_Logo_f_400px.png' # TODO: Replace this with the relative or absolute path of the image you want to convert
9+
10+ with open (image_path , 'rb' ) as f :
11+ image_bytes = f .read ()
12+
13+ url = 'https://www.labelzoom.net/api/v2/convert/png/to/zpl'
14+ headers = { 'Content-Type' : 'image/png' , 'Accept' : 'text/plain' }
15+ response = requests .post (url , data = image_bytes , headers = headers )
16+
17+ try :
18+ zpl = response .text
19+ print (zpl )
20+ except requests .exceptions .RequestException :
21+ print (response .text )
Original file line number Diff line number Diff line change 1+ #!/usr/bin/env python
2+ # -*- coding: utf-8 -*-
3+
4+ """print-zpl.py: Sends ZPL to a Zebra printer using a ZebraNet network adapter"""
5+
6+ import socket
7+
8+ zpl = '^XA^FO20,20^A0N,48^FDgithub.com/labelzoom^FS^XZ' # TODO: Replace this with the ZPL you want to print
9+ printer_ip_or_hostname = '192.168.0.44' # TODO: Replace this with the IP address or hostname of the printer
10+
11+ s = socket .socket (socket .AF_INET , socket .SOCK_STREAM )
12+ s .connect ((printer_ip_or_hostname , 9100 ))
13+ s .sendall (str .encode (zpl ))
14+ s .close ()
You can’t perform that action at this time.
0 commit comments