Simple python script to print 4x6 PDF/ZPL labels to Omezizy Bluetooth Thermal Label Printer. Used on CachyOS with printer connected over network.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Patrick Labbett d63088f4cb Initial commit: PDF-to-TSPL network label printer
Add printlabel.py, README, and .gitignore. Make printer host/port
configurable via LABEL_PRINTER_HOST/PORT env vars.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-25 14:45:56 -04:00
.gitignore Initial commit: PDF-to-TSPL network label printer 2026-07-25 14:45:56 -04:00
printlabel.py Initial commit: PDF-to-TSPL network label printer 2026-07-25 14:45:56 -04:00
README.md Initial commit: PDF-to-TSPL network label printer 2026-07-25 14:45:56 -04:00

label-maker

Render a PDF and print it to a network thermal label printer that speaks TSPL over a raw socket (JetDirect port 9100).

Built for 4" × 6" shipping labels on a 203 DPI direct-thermal printer.

How it works

printlabel.py takes a PDF, rasterizes each page to 1-bit mono with pdftoppm, then wraps the bitmap in a TSPL job (SIZE / GAP / BITMAP / PRINT) and streams it to the printer on TCP port 9100.

Requirements

  • Python 3
  • pdftoppm (from Poppler) on your PATH
  • A TSPL-compatible network printer reachable over TCP

On Debian/Ubuntu: sudo apt install poppler-utils

Usage

./printlabel.py label.pdf

The printer address defaults to 100.64.13.61:9100. Override it without editing the script:

LABEL_PRINTER_HOST=192.168.1.50 LABEL_PRINTER_PORT=9100 ./printlabel.py label.pdf

Configuration

Tunable constants at the top of printlabel.py:

Name Default Notes
DPI 203 Set to 300 for 300 DPI printers
LABEL_W, LABEL_H 4.0, 6.0 Label size in inches
GAP 0.12 Inter-label gap in inches

Progress (page dimensions in dots) and any printer response are written to stderr.