Skip to main content

Driver and generator for ZPL2 lables.

Project description

Python ZPL2 Library generates ZPL2 code which can be sent to Zebra or similar label printers. The library uses only Millimeter as unit and converts them internally according to printer settings.

Example use

import os
from PIL import Image
import zpl

l = zpl.Label(100,60)
height = 0
l.origin(0,0)
l.write_text("Problem?", char_height=10, char_width=8, line_width=60, justification='C')
l.endorigin()

height += 13
image_width = 5
l.origin((l.width-image_width)/2, height)
image_height = l.write_graphic(
    Image.open(os.path.join(os.path.dirname(zpl.__file__), 'trollface-large.png')),
    image_width)
l.endorigin()

height += image_height + 5
l.origin(10, height)
l.barcode('U', '07000002198', height=70, check_digit='Y')
l.endorigin()

l.origin(32, height)
l.barcode('Q', 'https://github.com/cod3monk/zpl/', magnification=5)
l.endorigin()

height += 20
l.origin(0, height)
l.write_text('Happy Troloween!', char_height=5, char_width=4, line_width=60,
             justification='C')
l.endorigin()

print(l.dumpZPL())
l.preview()

This will display the following preview image, generated using the Labelary API: label preview

The generated ZPL2 code is:

^XA^FO0,0^A0N,120,96^FB720,1,0,C,0^FDProblem?\&^FS^FO330,156^GFA,768,384,8,00003FFFC0000000000600000FF0000000180200C01F8000003008000000600000204080440D10000041080000000C000082420000CC020000840002000102000100200001008000010040000000800002000FF80000010006003F84003E01800C036F8200E100C01402307101FE01202878000E030000A071060200010001504201FC0000007C50821000000106C090A438000001800010A466001E0040115084A183C80070103042107009C044382060104E0800803A20300C40E00700F840380FE03C0003D8001A047021F83C588004027E2021845880020227E021047880020141F82187F8800100C07FFFFFF88001004047FFFFF88000803040FFFFF88000C00880419970800060078001117080001241C00012608000089038C237C08000060401FFF8008000011080000020000000C21040E0044000003863C0010840000006060000104000000180380080400000006000000080000000180000008000000007800001000000000038000600000000000380180000000000003FC000^FS^FO120,264^BUN,70,Y,N,Y^FD07000002198^FS^FO384,264^BQN,2,5,Q,7^FDQA,https://github.com/cod3monk/zpl/^FS^FO0,504^A0N,60,48^FB720,1,0,C,0^FDHappy Troloween!\&^FS^XZ

Installation

pip install --user zpl

Requirements

  • PIL or Pillow

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

zpl-0.1.13.tar.gz (421.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zpl-0.1.13-py3-none-any.whl (417.8 kB view details)

Uploaded Python 3

File details

Details for the file zpl-0.1.13.tar.gz.

File metadata

  • Download URL: zpl-0.1.13.tar.gz
  • Upload date:
  • Size: 421.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for zpl-0.1.13.tar.gz
Algorithm Hash digest
SHA256 69eb8c98146e27edc95e1937d92be303400338a0b257c115fbd3c9cadd8e4a40
MD5 10f0fc848d7d02e8ebbe6dd26e8d6cae
BLAKE2b-256 8fa0c6817ab725392130f289e3e3c03c114c0b7e0e636709ab62810d5bd0e186

See more details on using hashes here.

File details

Details for the file zpl-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: zpl-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 417.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for zpl-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 008017ebc9aa27602c25afdb3d13d452f7f6f5b14395bf22d10bb4327b54c0a6
MD5 abb2bc8118edd6a8084dea7cf4bb7072
BLAKE2b-256 59ea309ce258d57d57c076197e8ae15bcb485ee825091961e7efc9048522764c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page