Each owner whose software title is mentioned in this document has a Software License Agreement specific to
its proprietary programs.
Any trade names and product names of companies appearing on Brother products, related documents and
any other materials are all trademarks or registered trademarks of those respective companies.
IMPORTANT - PLEASE READ CAREFULLY
Note
This documentation (“Documentation”) provides information that will assist you in controlling your Printer
PT-P9XX (where “P9XX” is the model name).
You may use the Documentation only if you first agree to the following conditions.
If you do not agree to the following conditions, you may not use the Documentation.
Condition of Use
You may use and reproduce the Documentation to the extent necessary for your own use of your Printer
Model (“Purpose”). Unless expressly permitted in the Documentation, you may not;
(i) copy or reproduce the Documentation for any purpose other than the Purpose,
(ii) modify, translate or adapt the Documentation, and/or redistribute it to any third party,
(iii) rent or lease the Documentation to any third party, or,
(iv) remove or alter any copyright notices or proprietary rights legends included within the Documentation.
No Warranty
a. Any updates, upgrades or alteration of the Documentation or Printer Model will be performed at the sole
discretion of Brother. Brother may not respond to any request or inquiry about the Documentation.
b. THIS DOCUMENTATION IS PROVIDED TO YOU "AS IS" WITHOUT WARRANTY OF ANY KIND,
WHETHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTY
OF FITNESS FOR A PARTICULAR PURPOSE. BROTHER DOES NOT REPRESENT OR WARRANT
THAT THIS DOCUMENTATION IS FREE FROM ERRORS OR DEFECTS.
c. IN NO EVENT SHALL BROTHER BE LIABLE FOR ANY DIRECT, INDIRECT, PUNITIVE, INCIDENTAL,
SPECIAL OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER, ARISING OUT OF
THE USE, INABILITY TO USE, OR THE RESULTS OF USE OF THE DOCUMENTATION OR ANY
SOFTW ARE PROGRAM OR APPLICATION YOU DEVELOPED IN ACCORDANCE WITH THE
DOCUMENTATION.
ESC/P Command Reference
Contents
Introduction ····························································································1
What is ESC/P? ·······················································································2
1. Using ESC/P Commands ······································································3
2. Examples of Using ESC/P Commands ···················································5
Character code tables ........................................................................................................ 88
International character set table....................................................................................... 91
Appendix C: Introducing the Brother Developer Center ··························· 92
- ii -
ESC/P Command Reference
Introduction
This material provides the necessary information for directly controlling PT-P9XX.
This information is provided assuming that the user has full understanding of the operating system being used
and basic mastery of communication interfaces in a developer's environment.
Read the model names that appear in the screens in this manual as the name of your printer.
We accept no responsibility for any problems caused by programs that you develop using the information
provided in this material, affecting software, data or hardware, including the PT-P9XX, and any problems
resulting directly or indirectly from them. Use this material only if you accept these terms.
This material shall not be reproduced, in part or in full, without prior approval. In addition, this material shall
not be used as evidence in a lawsuit or dispute in a way that is unfavorable towards our company.
These ESC/P commands have been adapted specifically for this company.
- 1 Introduction
ESC/P Command Reference
What is ESC/P?
ESC/P is one type of control codes used for printers. With the codes introduced in this document, various
labels can be created and printed. In this document, ESC/P codes are provided as both ASCII and binary
codes.
When sending codes to the printer, make sure that the binary codes are used, otherwise the printer cannot
parse the codes.
- 2 -
What is ESC/P?
(1) Start ESC/P
1. Switch the command mode.
2. Initialize
- Switch command mode (ESC i a 0) Note: ESC/P mode
- Initialize (ESC @)
(2) Format settings
1. Select the orientation.
- Apply/cancel rotated printing (ESC i L)
2. Specify the line feed amount.
- Specify line feed amount (ESC 0, ESC 2, ESC 3 and ESC A)
(3) Print operations
1. Specify the print position.
- Specify vertical position (ESC J)
- Specify horizontal position (ESC $, ESC \ and ESC a)
2. Transfer the print data
(one line).
- If necessary, transfer text processing codes (see (4))
- bit images, bar codes and downloaded data (see (5))
3. End of the line.
- Feed the paper (CR and LF)
4. Repeat 1–3 above.
5. End of the page.
- Specify cut setting (ESC i C)
- Page feed (FF)
6. Repeat 1–5 above.
7. End of the document.
1. Using ESC/P Commands
Below is a description of the flow for creating documents.
Also refer to “2. Exam ples of Using ESC/P Commands”.
ESC/P Command Reference
- 3 -
1. Using ESC/P Commands
ESC/P Command Reference
(4) Text operations
1. Specify the character set.
- Select font (ESC k)
- Specify character size (ESC X)
2. Specify the character style.
- Specify character style
ESC SI, DC2, ESC - and ESC !)
3. Specify character codes.
* Repeat 1–3 above as necessary.
(5) Bit images, barcodes, and
image da ta
1. Specify bit images.
- (ESC *, ESC K, ESC L, ESC Y and ESC Z)
2. Specify barcodes.
- (ESC i B)
3. Specify 2D barcodes.
- (ESC i Q, ESC i V, ESC i D, ESC i M and ESC i J)
With transferred data, the image data must first be transferred and
- 4 -
1. Using ESC/P Commands
2. Examples of Using ESC/P Commands
Set Basic setup first.
Basic setup
Specify ESC/P command mode.
Basic set up : Specify ESC/P command mode
ESC/P Command Reference
Entered Command
ESC ia 00h
- 5 -
2. Examples of Using ESC/P Commands
This is the label that will be made.
ESC/P Command Reference
4 inches
1inch
Step 2:
Horizontal position
In order to make this label, the following four steps are required.
Step
Step 1:
Page length
Step 3:
Font type : Helsinki
(Bitmap fonts)
Step 4:
Character size :
24 points (120 dots)
1. Specify the tape length
2. Specify the horizontal position.
3. Select the font type.
4. Specify the character size.
- 6 -
2. Examples of Using ESC/P Commands
1 inch
Step 1: Specify the tape length
ESC/P Command Reference
4 inches
Step 2: Specify the horizontal position.
4 inches = 720 dots
Tape length = n1 + n2 * 256 = 720
↓ ↓
208 2
↓ ↓
D0h 02h
Entered Command
ESC il D0h 02h
1 inch = 60
Horizontal position = n1 + n2 * 256 = 60
↓ ↓
60 0
↓ ↓
3Ch 00h
- 7 -
Entered Command
ESC $ 3Ch 00h
2. Examples of Using ESC/P Commands
(Bitmap font)
Step 3: Select the font type.
ESC/P Command Reference
Font type : Helsinki
Step 4: Specify the character size.
Entered Command
ESC k 00h
Character size :
24 points (120 dots)
Entered Command
ESC X 36h
- 8 -
2. Examples of Using ESC/P Commands
Binary command: 1B 69 61 00
72 20 73 69 64 65
All commands together will make the example label shown below.
ESC/P Command Reference
Select ESC/P mode
ESC ia 00h
ESC @
ESC il D0h 02h
Initialize ESC/P mode
Binary command: 1B 40
ESC $ 3Ch 00h
4 steps explainde above
ESC k 00h
ESC X 36h
"At your side"
Text to be print
Binary command: 41 74 20 79 6F 75
FF
However, these commands should be converted to binary data before sent to the printer, as shown
below.
Here is the captured converted binary data.
Print start command
Binary command: 0C
When the printer receives above binary commands, the label shown below is printed.
- 9 -
2. Examples of Using ESC/P Commands
Width (①)
(tape width)
Printable area
Length (④) (label length)
Top margin
(
③)
Bottom
margin (③)
Right margin
(⑥)
Left margin (⑥)
②
⑤
Left/right
Max. no. of
printed lines
3. ESC/P Command Limitations
3.1 Print area
The print area for each tape width is listed below.
ESC/P Command Reference
Printable
Type
Width
Printable area
(vertical)
(mm)
(mm/dots)
Top/botto
m margins
(mm)
Length
(mm)
area
(horizontal)
margins
(mm)
Dot position
*1
mm/dots
①
②③④⑤⑥
36 36 32.0/454 2.00 46~499 18
24 24 22.6/320 0.71 113~432 13
18 18 16.5/234 0.75 156~389 9
12 12 10.6/150 0.71 198~247 6
9 9 7.5/106 0.76 220~325 4
6 6 4.5/64 0.74 241~304 2
3.5 3.5 2.5/36 0.74 255~290 1
HS24 23.6 18.1/256 2.9 145~400 10
HS18 17.7 15.0/212 1.4 167~378 8
HS12 11 .7 9.3/132 1.1 207~338 5
HS9 8.8 6.8/96 1.0 225~320 4
HS6 5.8 4.0/56 0.9 245~300 2
*1
The dot position for the lowest dot is specified as 1. (1~560)
The maximum length (④) is 1 m, and the minimum left and right margins (⑥) are 1 mm.
Fle label is recognized as 24mm width label.
- 10 -
3. ESC/P Command Limitations
ESC/P Command Reference
Half
Full
3.2 Characters
<Overseas> This system uses single-byte character codes and is installed with two bitmap fonts (Letter Gothic and
Helsinki).
Each font has six sizes: 21 dots, 28 dots, 44 dots, 56 dots, 88 dots and 120 dots.
3.2.1 Character sizes
<Overseas>
Each font is available in full size, compressed (half width) and double width.
size
width
Double width
Line-drawing characters (┘└ ┤─ ├ │ ┼ ┬ ┐┌) and shaded characters appear with the width of the Letter
Gothic font, regardless of the specified font setting.
- 11 -
3. ESC/P Command Limitations
ESC/P Command Reference
A
Print position
Baseline position
A
Print position
A
Baseline position
3.3 Print position
The print position is the standard position for printing characters, bitmaps and bar codes.
With the print position, there is a horizontal print position, which is the reference point for vertical position
movement.
3.3.1 Characters
Each character is arranged so that their top edge aligns with the print position.
The baseline of each character is the bottom edge of the character, regardless of size, font, etc.
All characters on the same line are printed so that the baseline position is the same for each character.
If the text consists of characters with different heights, the characters are aligned on the baseline of the tallest
character in the line of text.
In addition, underlines are printed 4 dots below the baseline position.
3.3.2 Bitmaps, barcodes and downloaded images
These types of image data are treated in the same way as characters and are printed so that the bottom edge
of the image aligns with the baseline.
A
- 12 -
3. ESC/P Command Limitations
ESC/P Command Reference
Line feed amount
3.4 Line feed amount
The line feed amount is the amount of vertical movement from the print position of one line to the print of the
next line.
HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
The line feed amount is specified using ESC 0, ESC 2, ESC A and ESC 3.
- 13 -
3. ESC/P Command Limitations
ESC/P Command Reference
ASCII Code
Binary Code
Description
ESC R
1B 52
Select international character set
ESC k
1B 6B
Select font
ESC t
1B 74
Select character code table
ASCII Code
Binary Code
Description
ESC 4
1B 34
Apply italic style
ESC 5
1B 35
Cancel italic style
ESC E
1B 45
Apply bold style
ESC F
1B 46
Cancel bold style
ESC G
1B 47
Apply double-strike printing
ESC H
1B 48
Cancel double-strike printing
ESC W
1B 57
Specify double-width characters
SI
0F
Specify compressed characters
ESC SI
1B 0F
Specify compressed characters
DC2
12
Cancel compressed characters
ESC -
1B 2D
Apply/cancel underlining
ESC !
1B 21
Global formatting
ESC X
1B 58
Specify character size
ESC if
1B 69 66
Apply/cancel a frame (global)
CAN
18
Clear text
DEL
7F
Delete one character
ESC CR
1B 0D
Not available
ASCII Code
Binary Code
Description
ESC 0
1B 30
Specify line feed of 1/8 inch
ESC 2
1B 32
Specify line feed of 1/6 inch
ESC 3
1B 33
Specify minimum line feed
ESC A
1B 41
Specify line feed of n/60 inch
4. Control Code List
Character/style selection commands (Refer to section 5.1 Character/style selection commands.)
Text printing commands (Refer to section 5.2 Text printing commands)
Line feed commands (Refer to section 5.3 Line feed commands.)
- 14 -
4. Control Code List
ASCII Code
Binary Code
Description
CR
0D
Carriage return
ESC $
1B 24
Specify absolute horizontal position
ESC \
1B 5C
Specify relative horizontal position
ESC a
1B 61
Specify alignment
ASCII Code
Binary Code
Description
LF
0A
Line feed
FF
0C
Page feed
ESC J
1B 4A
Forward paper feed
ASCII Code
Binary Code
Description
ESC i l
1B 69 6C
Specify label length
ESC i m
1B 69 6D
Specify margin width
ASCII Code
Binary Code
Description
ESC @
1B 40
Initialize
ASCII Code
Binary Code
Description
ESC *
1B 2A
Select bit image
ESC K
1B 4B
8-dot single-density bit image
ESC L
1B 4C
8-dot double-density bit image
ESC Y
1B 59
8-dot double-speed double-density bit image
ESC Z
1B 5A
8-dot quadruple-density bit image
Horizontal movement comm ands (Refer to section 5.4 Horizontal movement commands.)
Vertical movement commands (Refer to section 5.5 Vertical movement commands.)
Paper formatting commands (Refer to section 5.6 Paper formatting commands.)
ESC/P Command Reference
Printer control comm ands (Refer to section 5.7 Printer control commands.)
Graphics commands (Refer to section 5.8 Graphics commands.)
- 15 -
4. Control Code List
ASCII Code
Binary Code
Description
ESC i B
1B 69 42
Barcode
ESC i Q
1B 69 51
2D bar code (QR Code)
ESC i P
1B 69 50
Specify QR Code version
ESC i V
1B 69 56
2D bar code (PDF417)
ESC i D
1B 69 44
2D bar code (DataMatrix)
ESC i M
1B 69 4D
2D bar code (MaxiCode)
ESC i J
1B 69 4A
2D barcode (AztecCode)
ESC i F
1B 69 46
Print transferred data
ESC i a
1B 69 61
Switch command mode
ESC i S
1B 69 53
Request printer status
ESC i L
1B 69 4C
Apply/cancel rotated printing
ESC i C
1B 69 43
Specify cut setting
ESC i UB
1B 69 55 42
Specify baud rate
ESC i Ub
1B 69 55 62
Specify bit length
ESC i UP
1B 69 55 50
Specify parity setting
ESC i UC
1B 69 55 43
Specify busy control
ASCII Code
Binary Code
Description
ESC iXE2
1B 69 58 45 32
Specify barcode margin setting
ESC iXE1
1B 69 58 45 31
Retrieve barcode margin setting
Advanced commands (Refer to section 5.9 Advanced commands.)
ESC/P Command Reference
Advanced static commands (Refer to section 5.10 Advanced static commands.)
- 16 -
4. Control Code List
ESC/P Command Reference
n=0:
U.S.A
n=1:
France
n=2:
Germany
n=3:
UK
n=4:
Denmark I
n=5:
Sweden
n=6:
Italy
n=7:
Spain I
n=8:
Japan
n=9:
Norway
n=10:
Denmark II
n=11:
Spain II
n=12:
Latin America
n=13:
South Korea
n=64:
Legal
5. Control Command Details
5.1 Character/style selection commands
ESC R Select international character set
ASCII: ESC R n
Decim al: 27 82 n
Hexadecimal: 1B 52 n
Parameters
0≤n≤13, 64
Description
Selects the character set for the country, and switches some character codes in the code table according to
the value of n.
The following 12 codes are changed.
The default setting is n=0 (USA) for overseas.
When using the standard character code table, printing is performed according to the specified international