Skip to content

Latest commit

 

History

History
39 lines (32 loc) · 2.75 KB

README.md

File metadata and controls

39 lines (32 loc) · 2.75 KB

pyzpl2

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

Example use

l = Label(65,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 = 55
l.origin((l.width-image_width)/2, height)
image_height = l.write_graphic(Image.open('trollface-large.png'), image_width)
l.endorigin()

l.origin(0, height+image_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](http://api.labelary.com/v1/printers/12dpmm/labels/2.362205x1.181102/0/^XA^FO0,0^A0N,120,96^FB720,1,0,C,0^FDProblem?^FS^FO324,156^GFA,384,384,8,00000000000000000003FFFFFF800000000400FF007E0000001802001FF0C0000010103F000030000020420000F08C00004110E100000200000204020101010000840001008081000080200100000100010001E10100410003001F8C01000080060037C2007F00C00E203FE100FFBE201400801D07C0009038FC0102010001506103860001001C907200780001006210621800000183C030421600160040109042F1801800301010721062080038181042103C0D20401920300C21C0008038201A0F20380300DC401A04F013C0075C400C023C103FF64C4002023FA020824C00020123F020827C000100E07FFFFFFC0001004027FFFFFC0000803000FFFFF80000C018404FFFA8000060064041093800003041804109300000090070411360000004400FC13F804000031100000000400000C46000002040000030840E00044000000C0C1FC6084000000180C00020400000006001FF004000000018000000C0000000060000008000000001E0000100000000000F0006000000000000FFF000^FS^FO0,204^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^FO324,156^GFA,384,384,8,00000000000000000003FFFFFF800000000400FF007E0000001802001FF0C0000010103F000030000020420000F08C00004110E100000200000204020101010000840001008081000080200100000100010001E10100410003001F8C01000080060037C2007F00C00E203FE100FFBE201400801D07C0009038FC0102010001506103860001001C907200780001006210621800000183C030421600160040109042F1801800301010721062080038181042103C0D20401920300C21C0008038201A0F20380300DC401A04F013C0075C400C023C103FF64C4002023FA020824C00020123F020827C000100E07FFFFFFC0001004027FFFFFC0000803000FFFFF80000C018404FFFA8000060064041093800003041804109300000090070411360000004400FC13F804000031100000000400000C46000002040000030840E00044000000C0C1FC6084000000180C00020400000006001FF004000000018000000C0000000060000008000000001E0000100000000000F0006000000000000FFF000^FS^FO0,204^A0N,60,48^FB720,1,0,C,0^FDHappy Troloween!^FS^XZ

Requirements

  • PIL