Skip to content

Commit 6eab2de

Browse files
committed
Initial commit
1 parent 61ce302 commit 6eab2de

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
![LabelZoom Logo](https://www.labelzoom.net/assets/base/images/LabelZoom_Logo_f.svg)
12
# python-zpl-utils
23
A collection of Python scripts to improve the experience of owning a Zebra printer

png-to-zpl.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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)

print-zpl.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
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()

0 commit comments

Comments
 (0)