Web app for converting eBay shipping label PDFs to 4x6 thermal labels and printing to a TSPL-compatible thermal printer. Also includes a packing slip generator for BThrifty Online.
- Upload eBay shipping label PDFs via web interface
- Auto-detects label region on any page size using pixel analysis
- Rotates landscape labels 90° for portrait 4×6 printing
- Scales to fit inside 4×6 label (no distortion, no cutoff)
- Live preview of processed label before printing
- Prints to CUPS thermal printer queue
- Packing slip generator (
gen_packing_slip.py) for BThrifty Online
- Python 3.12+
- CUPS (for printer queue management)
- A TSPL-compatible thermal label printer (tested with YXWL Y42BT)
pip3 install flask pymupdf pillow numpygit clone https://github.com/zachsplat/Thermalprinter.git
cd Thermalprinterpip3 install flask pymupdf pillow numpyThe app expects a CUPS printer queue named Y42BT_TSPL with a 4×6 inch page size (w288h432).
The driver/ directory contains the required files:
Y42BT_TSPL.ppd— PPD file for the YXWL Y42BT thermal printerxprinter-tspl— CUPS filter (Python) that converts PDF to TSPL commands
Install the filter and create the queue:
# Install the CUPS filter
sudo cp driver/xprinter-tspl /usr/lib/cups/filter/xprinter-tspl
sudo chmod +x /usr/lib/cups/filter/xprinter-tspl
# Create the printer queue (adjust USB URI for your device)
lpadmin -p "Y42BT_TSPL" -E -v "usb:///Y42BT?serial=0000000" -P driver/Y42BT_TSPL.ppdVerify the printer is detected:
lpinfo -v
lpstat -p Y42BT_TSPLpython3 app.pyThe app listens on 0.0.0.0:5000 (all interfaces).
Create /etc/systemd/system/label-printer.service:
[Unit]
Description=Label Printer Web App
After=network.target
[Service]
Type=simple
User=YOUR_USERNAME
WorkingDirectory=/path/to/Thermalprinter
ExecStart=/usr/bin/python3 /path/to/Thermalprinter/app.py
Restart=always
RestartSec=5
Environment=PYTHONUNBUFFERED=1
[Install]
WantedBy=multi-user.targetEnable and start:
sudo systemctl daemon-reload
sudo systemctl enable label-printer.service
sudo systemctl start label-printer.serviceThe app binds to 0.0.0.0:5000, so if Tailscale is running on the host, you can access it from any device on your tailnet:
http://<tailscale-ip>:5000
Check your Tailscale IP with:
tailscale ip -4- Open the web app in your browser
- Upload an eBay shipping label PDF
- Preview the processed 4×6 label
- Click Print to send to the thermal printer
app.py— Flask web applicationtemplates/index.html— Web UIgen_packing_slip.py— Packing slip PDF generator for BThrifty Onlinetest_app.py— Test suitedriver/Y42BT_TSPL.ppd— PPD file for the YXWL Y42BT thermal printerdriver/xprinter-tspl— CUPS filter (PDF → TSPL)
Private repository. All rights reserved.