Quick reference for bar code control commands (HL-2150N / HL-2170W only)

The printer can print bar codes in the HP LaserJet emulation modes.

Print bar codes or expanded characters

Code
ESC i
Dec
27 105
Hex
1B 69
Format: ESC i n ... n \
Creates bar codes or expanded characters according to the segment of parameters ‘n ... n’. For more information about parameters, see the following Definition of Parameters. This command must end with the ‘ \ ’ code (5CH).

Definition of parameters

This bar code command can have the following parameters in the parameter segment (n ... n). As parameters are effective within the single command syntax ESC i n ... n \, they do not apply in the bar code commands. If certain parameters are not given, they take the preset settings. The last parameter must be the bar code data start (‘b’ or ‘B’) or the expanded character data start (‘l’ or ‘L’). Other parameters can be given in any sequence. Each parameter can start with a lower-case or upper-case character, for example, ‘t0’ or ‘T0’, ‘s3’ or ‘S3’ and so one.

Bar code mode

n = ‘t0’ or ‘T0’
CODE 39 (default)
n = ‘t1’ or ‘T1’
Interleaved 2 of 5
n = ‘t3’ or ‘T3’
FIM (US-Post Net)
n = ‘t4’ or ‘T4’
Post Net (US-Post Net)
n = ‘t5’ or ‘T5’
EAN 8, EAN 13, or UPC A
n = ‘t6’ or ‘T6’
UPC E
n = ‘t9’ or ‘T9’
Codabar
n = ‘t12’ or ‘T12’
Code 128 set A
n = ‘t13’ or ‘T13’
Code 128 set B
n = ‘t14’ or ‘T14’
Code 128 set C
n = ‘t130’ or ‘T130’
ISBN (EAN)
n = ‘t131’ or ‘T131’
ISBN (UPC-E)
n = ‘t132’ or ‘T132’
EAN 128 set A
n = ‘t133’ or ‘T133’
EAN 128 set B
n = ‘t134’ or ‘T134’
EAN 128 set C
This parameter selects the bar code mode as shown above. When n is ‘t5’ or ‘T5’ the bar code mode (EAN 8, EAN 13, or UPC A) varies according to the number of characters in the data.

Bar code, expanded character, line block drawing and box drawing

n = ‘s0’ or ‘S0’
3: 1 (default)
n = ‘s1’ or ‘S1’
2: 1
n = ‘s3’ or ‘S3’
2.5: 1
This parameter chooses the bar code style as above. When the EAN 8, EAN 13, UPC-A, Code 128 or EAN 128 bar code mode is chosen, this bar code style parameter is ignored.
If ‘S’ is followed by only one parameter, the parameter is a foreground fill pattern.

Bar code

n = ‘mnnn’ or ‘Mnnn’ (nnn = 0 ~ 32767)
This parameter shows the bar code width. The unit of ‘nnn’ is a percentage.

Bar code human readable line ON or OFF

n = ‘r0’ or ‘R0
Human readable line OFF
n = ‘r1’ or ‘R1
Human readable line ON
Preset:
Human readable line ON
 
(1) ‘T5’ or ‘t5’
 
(2) ‘T6’ or ‘t6’
 
(3) ‘T130’ or ‘t130’
 
(4) ‘T131’ or ‘t131’
Preset:
Human readable line OFF
All others
This parameter shows whether the printer prints the human readable line below the bar code. Human readable characters are always printed with OCR-B font of 10 pitch and all the current character style enhancements are masked. The default setting is determined by the bar code mode selected by ‘t’ or ‘T’.

Quiet zone

n = ‘onnn’ or ‘Onnn’ (nnn = 0 ~ 32767)
Quiet zone is the space on both sides of the bar codes. Its width can be shown using the units that are set by the ‘u’ or ‘U’ parameter. (For the description of ‘u' or ‘U' parameter, see the next section.) The default setting of the quiet-zone width is 1 inch.

Bar code, expanded character unit, line block drawing and box drawing

n = ‘u0’ or ‘U0’
mm (preset)
n = ‘u1’ or ‘U1’
1/10
n = ‘u2’ or ‘U2’
1/100
n = ‘u3’ or ‘U3’
1/12
n = ‘u4’ or ‘U4’
1/120
n = ‘u5’ or ‘U5’
1/10 mm
n = ‘u6’ or ‘U6’
1/300
n = ‘u7’ or ‘U7’
1/720
This parameter shows the measurement units of X-axis offset, Y-axis offset, and bar code height.

Bar code, expanded character, line block drawing and box drawing offset in X-axis

n = ‘xnnn’ or ‘Xnnn’
This parameter shows the offset from the left margin in the ‘u’- or ‘U’-specified unit.

Bar code & expanded character offset in Y-axis

n = ‘ynnn’ or ‘Ynnn’
This parameter shows the downward offset from the current print position in the ‘u’- or ‘U’-specified unit.

Bar code, expanded character, line block drawing and box drawing height

n = ‘hnnn’, ‘Hnnn’, ‘dnnn’, or ‘Dnnn’
1.
EAN13, EAN8, UPC-A, ISBN (EAN13, EAN8, UPC-A), ISBN (UPC-E): 22 mm
2.
UPC-E: 18 mm
3.
Others: 12 mm
Expanded characters Bsymbol.rarr 2.2 mm (preset)
Line block drawing and box drawing Bsymbol.rarr 1 dot
This parameter shows the height of bar codes or expanded characters as shown above. It can start with ‘h’, ‘H’, ‘d’, or ‘D’. The height of bar codes is shown in the ‘u’- or ‘U’-specified unit. The default setting of the bar code height (12 mm, 18 mm or 22 mm) is determined by the bar code mode selected by ‘t’ or ‘T’.

Expanded character width, line block drawing and box drawing

n = ‘wnnn’ or ‘Wnnn’
Expanded character Bsymbol.rarr 1.2 mm
Line block drawing and box drawing Bsymbol.rarr 1 dot
This parameter shows the width of expanded characters as shown above.

Expanded character rotation

n = ‘a0’ or ‘A0’
‘Upright (preset)
n = ‘a1’ or ‘A1’
‘Rotated 90 degrees
n = ‘a2’ or ‘A2’
‘Upside down, rotated 180 degrees
n = ‘a3’ or ‘A3’
‘Rotated 270 degrees

Bar code data start

n = ‘b’ or ‘B’
Data that follows ‘b’ or ‘B’ is read in as bar code data. Bar code data must end with the ‘ \ ’ code (5CH), which also ends this command. The acceptable bar code data is determined by the bar code mode selected by ‘t’ or ‘T’.
• 
When CODE 39 is chosen with the parameter ‘t0’ or ‘T0’
Forty three characters ‘0’ to ‘9’, ‘A’ to ‘Z’, ‘-’, ‘ . ’, ‘ (space)’, ‘$’, ‘ / ’, ‘+’, and ‘%’ can be accepted as bar code data. Other characters will cause a data error. The number of characters for bar codes is not limited. The bar code data automatically starts and ends with an asterisk ‘ * ’ (start character and stop character). If the received data has an asterisk ‘ * ’ at the beginning or end, the asterisk is regarded as a start character or stop character.
• 
When Interleaved 2 of 5 is selected with the parameter ‘t1’ or ‘T1’:
Ten numerical characters ‘0’ to ‘9’ can be accepted as bar code data. Other characters cause a data error. The number of characters for bar codes is not limited. This mode of bar codes needs even characters. If the bar code data has odd characters, ‘0’ is automatically added to the end of the bar code data.
• 
When FIM (US-Post Net) is selected with the parameter ‘t3’ or ‘T3’
Characters ‘A’ to ‘D’ are valid and one digit of data can be printed. Upper-case and lower-case alphabet characters can be accepted.
• 
When Post Net (US-Post Net) is selected with the parameter ‘t4’ or ‘T4’
Numbers ‘0’ to ‘9' can be data and it must end with a check digit. ‘?’ can be used instead of the check digit.
• 
When EAN 8, EAN 13, or UPC A is selected with the parameter ‘t5’ or ‘T5’
Ten numbers ‘0’ to ‘9’ can be accepted as bar code data. The number of characters for bar codes is limited as follows:
EAN 8: Total 8 digits (7 digits + 1 check digit)
EAN 13: Total 13 digits (12 digits + 1 check digit)
UPC A: Total 12 digits (11 digits + 1 check digit)
A number of characters other than those stated above will cause a data error that results in the bar code data being printed as normal print data. If the check digit is not correct, the printer decides the correct check digit automatically so that the correct bar code data will be printed. When EAN13 is selected, adding ‘+’ and a two-digit or five-digit number after the data can create an add-on code.
• 
When UPC-E is selected with the parameter ‘t6’ or ‘T6’:
The numbers ‘0’ to ‘9’ can be accepted as bar code data.
Eight digits1 2
(standard format) The first character must be ‘0’ and the data must end with a check digit.
Total eight digits = ‘0’ plus 6 digits plus 1 check digit.
Six digits2
The first character and the last check digit are removed from the eight digit data.
1
‘?’ can be used instead of a check digit.
2
Adding ‘+’ and two-digit or five-digit number after the data creates an add-on code.
• 
When Codebar is chosen with the parameter ‘t9’ or ‘T9’
Characters ‘0’ to ‘9’, ‘-’, ‘ . ’, ‘$’, ‘/’, ‘+’, ‘ : ’ can be printed. Characters ‘A’ to ‘D’ can be printed as a start-stop code, which can be upper case or lower case. If there is no start-stop code, errors will happen. A check digit cannot be added and using ‘?’ causes errors.
• 
When Code 128 Set A, Set B, or Set C is selected with the parameter ‘t12’ or ‘T12’, ‘t13’ or ‘T13’, or ‘t14’ or ‘T14’
Code 128 sets A, B and C can be individually selected. Set A shows characters Hex 00 to 5F. Set B includes characters Hex 20 to 7F. Set C includes the pairs 00 to 99. Switching is allowed between the code sets by sending %A, %B, or %C. FNC 1, 2, 3, and 4 are produced with %1, %2, %3, and %4. The SHIFT code, %S, allows temporary switching (for one character only) from set A to set B and vice versa. The ‘%’ character can be encoded by sending it twice.
• 
When ISBN (EAN) is selected with the parameter ‘t130’ or ‘T130’
The same rules apply as for ‘t5’ or ‘T5’.
• 
When ISBN (UPC-E) is selected with the parameter ‘t131’ or ‘T131’:
The same rules apply as for ‘t6’ or ‘T6’.
• 
When EAN 128 set A, set B or set C is selected with the parameter ‘t132’ or ‘T132’, ‘t133’ or ‘T133’ or ‘t134’ or ‘T134’
The same rules apply as for ‘t12’ or ‘T12’, ‘t13’ or ‘T13’, or ‘t14’ or ‘T14’.

Box drawing

ESC i ... E (or e)
‘E’ or ‘e’ is a terminator.

Line block drawing

ESC i ... V (or v)
‘V’ or ‘v’ is a terminator.

Expanded character data start

n = ‘l’ or ‘L’
Data that follows ‘l’ or ‘L’ is read as expanded character data (or labeling data). Expanded character data must end with the ‘ \ ’ code (5CH), which also ends this command.