zpl
===

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
-----------

.. code-block:: python

    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 <http://labelary.com/>`_:
`label preview <http://api.labelary.com/v1/printers/12dpmm/labels/2.362205x2.181102/0/^XA^FO0,0^A0N,120,96^FB720,1,0,C,0^FDProblem?\&^FS^FO330,156^GFA,768,384,8, ^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>`_

The generated ZPL2 code is:

::

   ^XA^FO0,0^A0N,120,96^FB720,1,0,C,0^FDProblem?\&^FS^FO330,156^GFA,768,384,8, ^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
