ZPL Document

class simple_zpl2.zpl_document.ANSICodabar_Barcode(data, orientation=None, height=None, print_text=None, text_above=None, start_character=None, stop_character=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

ANSI Codabar Bar Code (^BK)

Characters to encode (0-9)

Parameters:
  • data – barcode data numeric
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
  • start_character – ‘A’, ‘B’, ‘C’, ‘D’
  • stop_character – ‘A’, ‘B’, ‘C’, ‘D’
class simple_zpl2.zpl_document.Aztec_Barcode(data, orientation=None, magnification=None, ecic=None, ec_symbol_size=None, menu_symbol=None, number_of_symbols=None, structured_id_append=None)[source]

Bases: simple_zpl2.zpl_document._Barcode

Aztec Barcode (^B0 [zero] or ^BO [letter])

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • magnification – 1 to 10
  • ecic
    • ‘Y’ - data contains ECICs
    • ’N’ - does not contain ECICs
  • ec_symbol_size
    • 0 - default error correction
    • 01-99 - error correction percentage
    • 101-104 - 1-4 layer compact symbol
    • 201-232 - 1-32 layer full-range symbol
    • 300 - simple Aztec “Rune”
  • menu_symbol
    • ‘Y’ - a menu or barcode reader initialization sybmol
    • ’N’ - not menu symbol
  • number_of_symbols – Structured append 1-26 sybmols
  • structured_id_append – up to 24 character ID data
class simple_zpl2.zpl_document.CODABLOCK_Barcode(data, orientation=None, height=None, security_level=None, characters_per_row=None, row_count=None, mode='F')[source]

Bases: simple_zpl2.zpl_document._Barcode

CODABLOCK Bar Code (^BB)

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – height of individual dots (2 to 32000)
  • security_level – (‘Y’, ‘N’) only ‘N’ if mode is ‘A’
  • characters_per_row – 2-62
  • row_count – mode A: 1-22, mode E,F: 2-4
  • mode
    • ‘A’ - Code 39
    • ’F’ - Code 128
    • ’E’ - Code 128 with FNC1
class simple_zpl2.zpl_document.Code11_Barcode(data, orientation=None, check_digit=None, height=None, print_text=None, text_above=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

Code 11 Bar Code (^B1)

Characters to encode (0-9 and -)

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • check_digit
    • ‘Y’ - 1 digit
    • ’N’ - 2 digits
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
class simple_zpl2.zpl_document.Code128_Barcode(data, orientation, height=None, print_text=None, text_above=None, check_digit=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

Code 128 Barcode (^BC)

Only Code B is currently implemented, in the printable ASCII subset of ASCII > 95.

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
  • check_digit – Add Mod10 check digit to Mod103 (‘Y’, ‘N’)
class simple_zpl2.zpl_document.Code39_Barcode(data, orientation=None, check_digit=None, height=None, print_text=None, text_above=None, extended_ascii=False)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

Code 39 Bar Code (^B3)

Characters to encode (0-9, A-Z, -, ., $, /, +, %, ‘ ‘) with normal.

If scanner supports extended ASCII, with encode with +$ and -$

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • check_digit – calculate and print Mod 43 check digit (‘Y’, ‘N’)
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
class simple_zpl2.zpl_document.Code49_Barcode(data, orientation=None, height_multiplier=None, print_text=None, text_above=None, starting_mode=None)[source]

Bases: simple_zpl2.zpl_document._Barcode

Code 49 Bar Code (^B4)

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height_multiplier – 1 to height of label (recommending much more than 1)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
  • starting_mode
    • 0 - Regular Alphanumeric Mode
    • 1 - Multiple Read Alphanumeric
    • 2 - Regular Numeric Mode
    • 3 - Group Alphanumeric Mode
    • 4 - Regular Alphanumeric Shift 1
    • 5 - Regular Alphanumeric Shift 2
    • A - Automatic Mode. The printer determines the starting mode by analyzing the field data.
class simple_zpl2.zpl_document.Code93_Barcode(data, orientation=None, height=None, print_text=None, text_above=None, check_digit=None, extended_ascii=False)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

Code 93 Bar Code (^BA)

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
  • check_digit – print check digit (‘Y’, ‘N’)
class simple_zpl2.zpl_document.DataMatrix_Barcode(data, orientation=None, height=None, quality=None, columns=None, rows=None, format_id=None, escape_sequence=None, aspect_ratio=None)[source]

Bases: simple_zpl2.zpl_document._Barcode

Data Matrix Bar Code (^BX)

Parameters:
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – height of individual symbol elements 1-width of label
  • quality – amount of data added for error correction 0, 50, 80, 100, 140, 200
  • columns
    • columns to encode 9-49
    • odd values only for quality 0-140
    • even values for quality 200
  • rows – rows to encode 9-49
  • format_id
    • 1 = field data is numeric + space (0..9,”) – No &
    • 2 = field data is uppercase alphanumeric + space (A..Z,’’) – No &’’
    • 3 = field data is uppercase alphanumeric + space, period, comma, dash, and slash ( 0..9,A..Z,“.-/”)
    • 4 = field data is upper-case alphanumeric + space (0..9,A..Z,’’) – no &’’
    • 5 = field data is full 128 ASCII 7-bit set
    • 6 = field data is full 256 ISO 8-bit set
  • escape_sequence – any character
  • aspect_ratio
    • 1 = square
    • 2 = rectangular

Effects of ^BY on ^BX

w = module width (no effect)

r = ratio (no effect)

h = height of symbol

If the dimensions of individual symbol elements are not specified in the ^BY command, the height of symbol value is divided by the required rows/columns, rounded, limited to a minimum value of one, and used as the dimensions of individual symbol elements.

Field Data (^FD) for ^BX

Quality 000 to 140

  • The & and || can be used to insert carriage returns, line feeds, and the backslash, similar to the PDF417. Other characters in the control character range can be inserted only by using ^FH. Field data is limited to 596 characters for quality 0 to 140. Excess field data causes no symbol to print; if ^CV is active, INVALID-L prints. The field data must correspond to a user-specified format ID or no symbol prints; if ^CV is active, INVALID-C prints.
  • The maximum field sizes for quality 0 to 140 symbols are shown in the tktable in the g parameter.

Quality 200

  • If more than 3072 bytes are supplied as field data, it is truncated to 3072 bytes. This limits the maximum size of a numeric Data Matrix symbol to less than the 3116 numeric characters that the specification would allow. The maximum alphanumeric capacity is 2335 and the maximum 8-bit byte capacity is 1556.
  • If ^FH is used, field hexadecimal processing takes place before the escape sequence processing described below.
  • The underscore is the default escape sequence control character for quality 200 field data. A different escape sequence control character can be selected by using parameter g in the ^BX command.

The information that follows applies to firmware version: V60.13.0.12, V60.13.0.12Z, V60.13.0.12B, V60.13.0.12ZB, or later. The input string escape sequences can be embedded in quality 200 field data using the ASCII 95 underscore character ( _ ) or the character entered in parameter g:

  • _X is the shift character for control characters (e.g., _@=NUL,_G=BEL,_0 is PAD)
  • _1 to _3 for FNC characters 1 to 3 (explicit FNC4, upper shift, is not allowed)
  • FNC2 (Structured Append) must be followed by nine digits, composed of three-digit numbers with values between 1 and 254, that represent the symbol sequence and file identifier (for example, symbol 3 of 7 with file ID 1001 is represented by _2214001001)
  • 5NNN is code page NNN where NNN is a three-digit code page value (for example, Code Page 9 is represented by _5009)
  • _dNNN creates ASCII decimal value NNN for a code word (must be three digits)
  • _ in data is encoded by __ (two underscores) The information that follows applies to all other versions of firmware. The input string escape sequences can be embedded in quality 200 field data using the ASCII 7E tilde character (~) or the character entered in parameter g:
  • ~X is the shift character for control characters (e.g., ~@=NUL,~G=BEL,~0 is PAD)
  • ~1 to ~3 for FNC characters 1 to 3 (explicit FNC4, upper shift, is not allowed)
  • FNC2 (Structured Append) must be followed by nine digits, composed of three-digit numbers with values between 1 and 254, that represent the symbol sequence and file identifier (for example, symbol 3 of 7 with file ID 1001 is represented by ~2214001001)
  • 5NNN is code page NNN where NNN is a three-digit code page value (for example, Code Page 9 is represented by ~5009)
  • ~dNNN creates ASCII decimal value NNN for a code word (must be three digits)
  • ~ in data is encoded by a ~ (tilde)
class simple_zpl2.zpl_document.EAN13_Barcode(data, orientation=None, height=None, print_text=None, text_above=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

EAN-13 Bar Code (^BE)

Following Field data is limited to exactly 12 characters.

Parameters:
  • data – numeric data only and 12 numerals. Truncated or padded to 12.
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
class simple_zpl2.zpl_document.EAN8_Barcode(data, orientation=None, height=None, print_text=None, text_above=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

EAN 8 Bar Code (^B8)

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
class simple_zpl2.zpl_document.GS1Databar_Barcode(gtin_data, composite_data=None, orientation='R', symbology_type=1, magnification=3, separator_height=1, bar_height=25, segment_width=22)[source]

Bases: simple_zpl2.zpl_document._Barcode

GS1 Databar Bar Code (^BR)

Parameters:
  • gtin_data – GTIN-12 or GTIN13 data
  • composite_data – optional additional data
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • symbology_type
    • 1 = GS1 DataBar Omnidirectional
    • 2 = GS1 DataBar Truncated
    • 3 = GS1 DataBar Stacked
    • 4 = GS1 DataBar Stacked Omnidirectional
    • 5 = GS1 DataBar Limited
    • 6 = GS1 DataBar Expanded
    • 7 = UPC-A
    • 8 = UPC-E
    • 9 = EAN-13
    • 10 = EAN-8
    • 11 = UCC/EAN-128 and CC-A/B
    • 12 = UCC/EAN-128 and CC-C
  • magnification – 1-10
  • separator_height – 1 or 2
  • bar_height – bar code height 1-32000 dots
  • segment_width – 2 - 22 (even numbers only)
class simple_zpl2.zpl_document.Industrial2of5_Barcode(data, orientation=None, height=None, print_text=None, text_above=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

Industrial 2 of 5 Bar Code (^BI)

Characters to encode (0-9)

Parameters:
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
class simple_zpl2.zpl_document.Interleaved2of5_Barcode(data, orientation=None, height=None, print_text=None, text_above=None, check_digit=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

Interleaved 2 of 5 Bar Code (^B2)

Characters to encode (0-9)

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
  • check_digit – calculate and print Mod 10 check digit (‘Y’, ‘N’)
class simple_zpl2.zpl_document.LOGMARS_Barcode(data, orientation=None, height=None, text_above=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

LOGMARS Bar Code (^BL)

This is a special application of Code 39 used by Department of Defense. LOGMARS - Logistics Applications of Automated Marking and Reading Symbols

Parameters:
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • text_above – print text above barcode (‘Y’, ‘N’)
class simple_zpl2.zpl_document.MSI_Barcode(data)[source]

Bases: simple_zpl2.zpl_document._Barcode

MSI Bar Code (^BM)

Characters to encode (0-9)

Parameters:
  • data – barcode data numeric only
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • check_digit
    • A - no check digits
    • B - 1 Mod 10
    • C - 2 Mod 10
    • D - 1 Mod 11 and 1 Mod 10
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
  • insert_check_digit – Add check digit to text line (‘Y’, ‘N’)
add_barcode_msi(*args, **kwargs)[source]
class simple_zpl2.zpl_document.MicroPDF417_Barcode(data, orientation=None, height=None, mode=None)[source]

Bases: simple_zpl2.zpl_document._PDF_Barcode

MicroPDF417 Bar Code (^BF)

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 9999)
  • mode – 0-33

Note

To encode data into a MicroPDF417 bar code, complete these steps:

1. Determine the type of data to be encoded (for example, ASCII characters, numbers, 8-bit data, or a combination).

2. Determine the maximum amount of data to be encoded within the bar code (for example, number of ASCII characters, quantity of numbers, or quantity of 8-bit data characters).

3. Determine the percentage of check digits that are used within the bar code. The higher the percentage of check digits that are used, the more resistant the bar code is to damage — however, the size of the bar code increases.

4. Use Table with the information gathered from the questions above to select the mode of the bar code.

MO - mode

DC - Number of Data Columns

DR - Number of Data Rows

EC - % of CWS for EC

MX - Max Alpha Characters

MD - Max Digits

MO DC DR EC MX MD
0 1 11 64 6 8
1 1 14 50 12 17
2 1 17 41 18 26
3 1 20 40 22 32
4 1 24 33 30 44
5 1 28 29 38 55
6 2 8 50 14 20
7 2 11 41 24 35
8 2 14 32 36 52
9 2 17 29 46 67
10 2 20 28 56 82
11 2 23 28 64 93
12 2 26 29 72 105
13 3 6 67 10 14
14 3 8 58 18 26
15 3 10 53 26 38
16 3 12 50 34 49
17 3 15 47 46 67
18 3 20 43 66 96
19 3 26 41 90 132
20 3 32 40 114 167
21 3 38 39 138 202
22 3 44 38 162 237
23 4 6 50 22 32
24 4 8 44 34 49
25 4 10 40 46 67
26 4 12 38 58 85
27 4 15 35 76 111
28 4 20 33 106 155
29 4 26 31 142 208
30 4 32 30 178 261
31 4 38 29 214 313
32 4 44 28 250 366
33 4 4 50 14 20
multiple_field_origin(*args)

Adds ^FM Multiple Field Origin Locations

Pass in pairs of x, y with a limit of 60 pairs

Parameters:args – x1, y1 0 to 32000 or e to exclude
class simple_zpl2.zpl_document.PDF417_Barcode(data, orientation=None, height=None, security_level=None, data_column_count=None, row_count=None, truncate=None)[source]

Bases: simple_zpl2.zpl_document._PDF_Barcode

PDF417 Bar Code (^B7)

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – height of individual dots, recommends larger than 1
  • security_level – 0 - error detection only, 1-8 correction level
  • data_column_count – number of code word columns (1-30)
  • row_count – number of rows to encode (3-90)
  • truncate – truncate right row indicators and stop pattern (‘Y’, ‘N’)
multiple_field_origin(*args)

Adds ^FM Multiple Field Origin Locations

Pass in pairs of x, y with a limit of 60 pairs

Parameters:args – x1, y1 0 to 32000 or e to exclude
class simple_zpl2.zpl_document.PlanetCode_Barcode(data, orientation=None, height=None, print_text=None, text_above=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

Planet Code Bar Code (^B5)

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 9999)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
class simple_zpl2.zpl_document.Plessey_Barcode(data, orientation=None, check_digit=None, height=None, print_text=None, text_above=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

Plessey Bar Code (^BP)

Characters to encode (0-9 A-F)

Parameters:
  • data – data for barcode 0-9 or A-F
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • check_digit – print check digit (‘Y’, ‘N’)
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
class simple_zpl2.zpl_document.Postal_Barcode(data, orientation=None, height=None, print_text=None, text_above=None, code_type=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

Postal Bar Code (^BZ)

Characters (0-9)

Parameters:
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
  • code_type
    • 0 = Postnet bar code
    • 1 = Plant Bar Code
    • 2 = Reserved
    • 3 = USPS Intelligent Mail bar code
class simple_zpl2.zpl_document.QR_Barcode(data, model=None, magnification=None, error_correction='M', mask_value=None, fd_switches='M, A')[source]

Bases: simple_zpl2.zpl_document._Barcode

QR Barcode (^BQ)

Parameters:
  • model – 1 - original, 2 - enhanced
  • magnification – 1 to 10
  • error_correction
    • ‘H’ - ultra-high
    • ’Q’ - high’
    • ’M’ - standard
    • ’L’ - low
  • mask_value – 0-7 defaults 7
  • fd_switches – sets data-input mode between Automatic(‘A’), Manual(‘M’) and character mode <N, A, Bdddd, K>. Defaults to M,A, for Manual data input, and automatic character mode. See below for documentation on Mixed Mode and Character-mode.

Note

QR Switches (formatted into the ^FD field data) There are 4 switch fields that are allowed, some with associated parameters and some without. Two of these fields are always present, one is optional, and one’s presence depends on the value of another. The switches are always placed in a fixed order. The four switches, in order are:

Mixed mode <D>iijjxx,Optional (note that this switch ends with a comma “,”) Error correction level <H, Q, M, L>Mandatory Data input <A, M>,Mandatory (note that this switch ends with a comma “,”) Character Mode <N, A, Bdddd, K>Conditional (present if data input is M)

Mixed mode (Optional)

= D - allows mixing of different types of character modes in one code. ii = code No. – a 2 digit number in the range 01 to 16 Value = subtracted from the Nth number of the divided code (must be two digits). jj = No. of divisions – a 2 digit number in the range 02 to 16 Number of divisions (must be two digits). xx = parity data – a 2 digit hexadecimal character in the range 00 to FF Parity data value is obtained by calculating at the input data (the original input data before divided byte-by-byte through the EX-OR operation). , = the mixed mode switch, when present, is terminated with a comma
Error correction level (Required)

= H, Q, M, or L

  • H = ultra-high reliability level
  • Q = high reliability level
  • M = standard level (default)
  • L = high density level
Data input (Required)

= A or M followed by a comma

  • A = Automatic Input (default). Character Mode is not specified. Data character string JIS8 unit, Shift JIS. When the input mode is Automatic Input, the binary codes of 0x80 to 0x9F and 0xE0 to 0xFF cannot be set.
  • M = Manual Input. Character Mode must be specified. Two types of data input mode exist: Automatic (A) and Manual (M). If A is specified, the character mode does not need to be specified. If M is specified, the character mode must be specified.
Character Mode (Required when data input = M)

= N, A, Bxxxx, or K

  • N = numeric: digits 0 – 9
  • A = alphanumeric: digits 0 – 9, upper case letters A – Z, space, and $%*+-./:) (45 characters)
  • Bxxxx = 8-bit byte mode. The ‘xxxx’ is the number of characters and must be exactly 4 decimal digits. This handles the 8-bit Latin/Kana character set in accordance with JIS X 0201 (character values 0x00 to 0xFF).
  • K = Kanji — handles only Kanji characters in accordance with the Shift JIS system based on JIS X 0208. This means that all parameters after the character mode K should be 16-bit characters. If there are any 8-bit characters (such as ASCII code), an error occurs. The data to be encoded follows immediately after the last switch.

Considerations for ^FD When Using the QR Code:

QR Switches (formatted into the ^FD field data)

mixed mode <D>
D = allows mixing of different types of character modes in one code. code No. <01 16> Value = subtracted from the Nth number of the divided code (must be two digits).
No. of divisions <02 16>
Number of divisions (must be two digits).
parity data <1 byte>
Parity data value is obtained by calculating at the input data (the original input data before divided byte-by-byte through the EX-OR operation).
error correction level <H, Q, M, L>
  • H = ultra-high reliability level
  • Q = high reliability level
  • M = standard level (default)
  • L = high density level
character Mode <N, A, B, K>
  • N = numeric
  • A = alphanumeric
  • Bxxxx = 8-bit byte mode. This handles the 8-bit Latin/Kana character set in accordance with JIS X 0201 (character values 0x00 to 0xFF). xxxx = number of data characters is represented by two bytes of BCD code.
  • K = Kanji — handles only Kanji characters in accordance with the Shift JIS system based on JIS X 0208. This means that all parameters after the character mode K should be 16-bit characters. If there are any 8-bit characters (such as ASCII code), an error occurs.
data character string <Data>
Follows character mode or it is the last switch in the ^FD statement.
data input <A, M>
  • A = Automatic Input (default). Data character string JIS8 unit, Shift JIS. When the input mode is Automatic Input, the binary codes of 0x80 to 0x9F and 0xE0 to 0xFF cannot be set.
  • M = Manual Input Two types of data input mode exist: Automatic (A) and Manual (M). If A is specified, the character mode does not need to be specified. If M is specified, the character mode must be specified.
^FD Field Data (Normal Mode)
Automatic Data Input (A) with Switches ^FD <error correction level>A, <data character string> ^FS
Manual Data Input (M) with Switches
^FD <error correction level>M, <character mode><data character string> ^FS
^FD Field Data (Mixed Mode – requires more switches)
Automatic Data Input (A) with Switches ^FD <D><code No.> <No. of divisions> <parity data>, <error correction level> A, <data character string>, <data character string>, < : >, <data character string n**> ^FS
Manual Data Input (M) with Switches

^FD <code No.> <No. of divisions> <parity data>, <error correction level> M, <character mode 1> <data character string 1>, <character mode 2> <data character string 2>, < : > < : >, <character mode n> <data character string n**> ^FS

n** up to 200 in mixed mode

class simple_zpl2.zpl_document.Standard2of5_Barcode(data, orientation=None, height=None, print_text=None, text_above=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

Standard 2 of 5 Bar Code (^BJ)

Characters to encode (0-9)

Parameters:
  • data – barcode data numeric characters
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
class simple_zpl2.zpl_document.TLC39_Barcode(orientation=None, code_39_width=None, code_39_ratio=None, code_39_height=None, micropdf417_height=None, micropdf417_width=None)[source]

Bases: simple_zpl2.zpl_document._BaseZPL

TLC39 Bar Code (^BT)

Parameters:
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • code_39_width – width of the Code 39 bar code 1-10
  • code_39_ratio – wide to narrow bar width ratio of Code 39 bar code 2.0-3.0 by 0.1
  • code_39_height – height of the Code 39 bar code 1-9999
  • micropdf417_height – height of MicroPDF417 bar code 1-255
  • micropdf417_width – width of MicroPDF417 bar code 1-10

Note

ECI Number.

If the seventh character is not a comma, only Code 39 prints. This means if more than 6 digits are present, Code 39 prints for the first six digits (and no Micro-PDF symbol is printed).

  • Must be 6 digits.
  • Firmware generates invalid character error if the firmware sees anything but 6 digits.
  • This number is not padded.

Serial number.

The serial number can contain up to 25 characters and is variable length. The serial number is stored in the Micro-PDF symbol. If a comma follows the serial number, then additional data is used below.

  • If present, must be alphanumeric (letters and numbers, no punctuation). This value is used if a comma follows the ECI number.

Additional data.

If present, it is used for things such as a country code. Data cannot exceed 150 bytes. This includes serial number commas.

  • Additional data is stored in the Micro-PDF symbol and appended after the serial number. A comma must exist between each maximum of 25 characters in the additional fields.
  • Additional data fields can contain up to 25 alphanumeric characters per field.
add_data(eci_number, serial_number=None, additional_data=None)[source]

Add data field for tlc39 barcode

Parameters:
  • eci_number – exactly 6 digit number
  • serial_number – optional up to 26 character alphanumeric
  • additional_data – string or list/tuple
class simple_zpl2.zpl_document.UPC_A_Barcode(data, orientation, height, print_text='Y', text_above='N', check_digit='Y')[source]

Bases: simple_zpl2.zpl_document._1DBarcode

UPC-A Bar Code (^BU)

Parameters:
  • data – barcode data
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 9999)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
  • check_digit – print check digit (‘Y’, ‘N’)
class simple_zpl2.zpl_document.UPC_Barcode(data, orientation=None, height=None, print_text=None, text_above=None, check_digit=None)[source]

Bases: simple_zpl2.zpl_document._1DBarcode

UPC-E Bar Code (^B9)

Parameters:
  • data – data for barcode
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
  • check_digit – print check digit (‘Y’, ‘N’)
class simple_zpl2.zpl_document.UPC_EAN_Extensions_Barcode(data, orientation='N', height=100, print_text='Y', text_above='Y')[source]

Bases: simple_zpl2.zpl_document._1DBarcode

UPC/EAN Extensions Bar Code (^BS)

Parameters:
  • data – barcode data
  • orientation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • height – bar code height in dots (1 to 32000)
  • print_text – print text of data (‘Y’, ‘N’)
  • text_above – print text above barcode (‘Y’, ‘N’)
class simple_zpl2.zpl_document.UPSMaxicode_Barcode(mode=None, symbol_number=None, symbol_count=None)[source]

Bases: simple_zpl2.zpl_document._Barcode

UPS MaxiCode Bar Code

Note: Data adding isn’t completed. Must be done with manual add_data_field.

Parameters:
  • mode
    • 2 - structured carrier message: numeric postal code (U.S.)
    • 3 - structured carrier message: alphanumeric postal code (non-U.S.)
    • 4 - standard symbol, secretary
    • 5 - full EEC
    • 6 - reader program, secretary
  • symbol_number – 1-8
  • symbol_count – 1-8

Considerations for ^FD when Using ^BD The ^FD statement is divided into two parts: a high priority message (hpm) and a low priority message (lpm). There are two types of high priority messages. One is for a U.S. Style Postal Code; the other is for a non-U.S. Style Postal Code. The syntax for either of these high priority messages must be exactly as shown or an error message is generated. Format: ^FD <hpm><lpm>

<hpm> = high priority message (applicable only in Modes 2 and 3)

Values: 0 to 9, except where noted U.S. Style Postal Code (Mode 2)

<hpm> = aaabbbcccccdddd aaa = three-digit class of service bbb = three-digit country zip code ccccc = five-digit zip code dddd = four-digit zip code extension (if none exists, four zeros (0000) must be entered)
non-U.S. Style Postal Code (Mode 3)
<hpm> = aaabbbcccccc aaa = three-digit class of service bbb = three-digit country zip code ccccc = six-digit zip code (A through Z or 0 to 9)
<lpm> = low priority message (only applicable in Modes 2 and 3)

GS is used to separate fields in a message (0x1D). RS is used to separate format types (0x1E). EOT is the end of transmission characters.

Message Header [)>RS Transportation Data Format Header01GS96 Tracking Number*<tracking number> SCAC*GS<SCAC> UPS Shipper NumberGS<shipper number> Julian Day of PickupGS<day of pickup> Shipment ID NumberGS<shipment ID number> Package n/xGS<n/x> Package WeightGS<weight> Address ValidationGS<validation> Ship to Street AddressGS<street address> Ship to CityGS<city> Ship to StateGS<state> RSRS End of MessageEOT (* Mandatory Data for UPS)

Comments • The formatting of <hpm> and <lpm> apply only when using Modes 2 and 3. Mode 4, for example, takes whatever data is defined in the ^FD command and places it in the symbol. • UPS requires that certain data be present in a defined manner. When formatting MaxiCode data for UPS, always use uppercase characters. When filling in the fields in the <lpm> for UPS, follow the data size and types specified in Guide to Bar Coding with UPS. • If you do not choose a mode, the default is Mode 2. If you use non-U.S. Postal Codes, you probably get an error message (invalid character or message too short). When using non-U.S. codes, use Mode 3. • ZPL II doesn’t automatically change your mode based on the zip code format. • When using special characters, such as GS, RS, or EOT, use the ^FH command to tell ZPL II to use the hexadecimal value following the underscore character ( _ ).

class simple_zpl2.zpl_document.ZPLDocument[source]

Bases: simple_zpl2.zpl_document._BaseZPL

Builds ZPL II label data based on methods called and data passed.

Note

Dots to real measurements based on printer dpi:

  • 150 dpi: 6 dots = 1 mm, 152 dots = 1 in,
  • 200 dpi: 8 dots = 1 mm, 203 dots = 1 in,
  • 300 dpi: 12 dots = 1 mm, 300 dots = 1 in,
  • 600 dpi: 24 dots = 1mm, 600 dots = 1 in
add_barcode(barcode_object)[source]
add_barcode_default(*args, **kwargs)[source]

Set defaults for bar codes (^BY)

Parameters:
  • module_width – 1 to 10 dots (default 2)
  • wide_narrow_ratio – 2.0 to 3.0 is 0.1 increments (default 3.0)
  • height – bar code height in dots (default 10)
add_comment(*args, **kwargs)[source]

Comment Block (^FX)

Parameters:comment_text – Text to insert as comment
add_default_font(*args, **kwargs)[source]

Specify default font to use for all text fields (^CF)

Parameters:
  • font_name – A-Z or 0-9 of font stored in printer
  • character_height – 10 to 32000 dots
  • character_width – 10 to 32000 dots
add_field_block(width=0, max_lines=1, dots_between_lines=0, text_justification='L', hanging_indent=0)[source]

Field Block (^FB)

Parameters:
  • width – width of text 0 to label width
  • max_lines – max number of lines in block, 1 to 9999
  • dots_between_lines – dots between line adjustment -9999 to 9999
  • text_justification
    • ‘L’ - Left
    • ’C’ - center
    • ’R’ - right
    • ’J’ - justified
  • hanging_indent – 0 to 9999
add_field_data(data_list, replace_newlines=False)[source]

Field Data for Text or Barcode (^FD with 1-many ^FS)

param data_list:
 if list or tuple, multiple data blocks with ‘^FS’ separator otherwise, single field with value
param replace_newlines:
 If true, replaces

with &

add_field_origin(*args, **kwargs)[source]

Field Origin (^FO)

Location where Field should start.

Parameters:
  • x_pos – x axis position in dots (0 to 32000)
  • y_pos – y axis position in dots (0 to 32000)
  • justification
    • 0 - left
    • 1 - right
    • 2 - auto
add_font(*args, **kwargs)[source]

Specify font to use in text field (^A)

Parameters:
  • font_name – A-Z or 0-9 of font stored in printer
  • orientation
    • ‘N’ - Normal
    • ’R’ - Rotated 90 clockwise
    • ’I’ - Inverted
    • ’B’ - Bottom Up (270 rotate)
  • character_height – 10 to 32000 dots
  • width – 10 to 32000 dots
add_graphic_box(*args, **kwargs)[source]

Produce Graphic Box on Label (^GB)

Parameters:
  • width – border to 32000
  • height – border to 32000
  • border – 1 to 32000
  • line_color
    • ‘B’ - black
    • ’W’ - white
  • corner_rounding – 0 (none) to 8 (heaviest rounding)
add_graphic_circle(*args, **kwargs)[source]

Produce Circle on Label (^GC)

Parameters:
  • diameter – 3 to 4095
  • border – 1 to 4095
  • color
    • ‘B’ - black
    • ’W’ - white
add_graphic_diagnonal_line(*args, **kwargs)[source]

Produce Diagonal Line on Label (^GD)

Parameters:
  • width – border to 32000
  • height – border to 32000
  • border – 1 to 32000
  • line_color
    • ‘B’ - black
    • ’W’ - white
  • orientation – ‘L’ for left-leaning diagonal () (default) , ‘R’ for right-leaning diagonal (/)
add_graphic_field(*args, **kwargs)[source]

Produce Graphic Field on Label (^GF)

Parameters:
  • image – PIL image
  • width – border to 99999
  • height – border to 99999
  • compression_type
    • ‘A’ - ASCII hexadecimal
    • ’B’ - binary
    • ’C’ - compressed binary
add_label_home(*args, **kwargs)[source]

Label Home Position (^LH)

Parameters:
  • x_pos – x axis position in dots (0 to 32000)
  • y_pos – y axis position in dots (0 to 32000)
add_print_quantity(*args, **kwargs)[source]

Control Printing Quantity and Pausing (^PQ)

Parameters:
  • quantity – total quantity of labels to print (1 to 99,999,999)
  • pause_and_cut_count – number before pause and cut (0 to 99,999,999 with 0 as disabled)
  • replicates_of_serial – number of serial duplicates (0 to 99,999,999 with 0 as none)
  • override_pause – override pause count (‘Y’, ‘N’)
  • cut_on_error – cut on RFID void error label (‘Y’, ‘N’)
add_printer_sleep(*args, **kwargs)[source]

Place printer in sleep mode (^ZZ)

Only valid on battery powered printers.

Parameters:
  • sleep_seconds – 0 to 9999999 (0 sleep disabled)
  • shutdown_while_queued
    • ‘Y’ - Shutdown, even if labels are queued
    • ’N’ - Print labels before shutdown
add_serialization_data(*args, **kwargs)[source]

Create data field and increment or decrement values. (^SN)

Parameters:
  • starting_value – max of 12 digit number
  • change_value – max of 12 digit number (‘-’ prefix for decrement)
  • add_leading_zeros – ‘Y’ or ‘N’
add_start_print(*args, **kwargs)[source]

Start Print (^SP)

This allows printing parts of label while other is being transmitted and formatted.

Example: add_start_print(500), will print Segment 1

+——————————-+ Dot position 0 | | | Label Segment 2 | | | + - - - - - - - - - - - - - - - + Dot position 500 | | | Label Segment 1 | | | +——————————-+ Dot position 1000
Parameters:dot_row_start_printing – 0 to 32000 to print to for segment
add_text_blocks(*args, **kwargs)[source]
Parameters:
  • block_rotation
    • ‘N’ - normal
    • ’R’ - rotate 90
    • ’I’ - inverted
    • ’B’ - rotate 270
  • block_width – 1 to label width in dots
  • block_height – 1 to label length in dots
add_zpl_raw(*args, **kwargs)[source]

Used to add raw ZPLII to the document, to cover any ZPL Commands not coded via existing methods.

Parameters:zpl_data – Raw zpl data
render_png(label_width, label_height, dpmm=8, index=0)[source]

Uses labelary.com api to generate a PNG file

See: examples/display_label_png.py

Parameters:
  • label_width – width in inches
  • label_height – height in inches
  • dpmm – dots per mm, default 8
  • index – label index (only important if you use in label)
Returns:

byte array of PNG file

zpl_bytes

Renders zpl code as bytestring in UTF-8 formatting.

This is what you would typically send to a printer.

Returns:byte array
zpl_text

Renders zpl text as string for debugging.

Parameters:strip_newline – Default False,
Returns:text string