Professional Documents
Culture Documents
Fidcal
TECHZONE
The Epson
ESC/P &
ESC/P2
Printer
Codes
Many printer code lists are either in code order (OK for hacking but
useless for setting up a print job!) or grouped in types (so for 'bold print'
you would need to first find out then always remember that it's in the
'style' group (or some other name); for a new line you would probably
have to know that it's in the 'move' group. But THIS list is in simple
alphabetic order of the function needed. So, if, for example, you want to
start a new line, you simply look under N for New Line.
Many functions are entered several times under different names, eg, 'new
line' is also under 'line feed' because not everyone uses the same
definitions. If any of YOUR preferred definitions are not there you can edit
or add to the list in a web page editor or in any plain ASCII text editor if
you know how to edit simple html text.
Typically in BASIC you would enter them by using LPRINT CHR$(n). For
www.fidcal.com/printercodes/ 1/14
4/1/13 Epson ESC/P and ESC/P2 Printer Codes
Typically in BASIC you would enter them by using LPRINT CHR$(n). For
example, to print with emphasised characters, the codes are 27,69 which
would be entered in BASIC as LPRINT CHR$(27);CHR$(69).
Note that when a value is the ASCII code for a quotable character then
the character can be used (within quotes) instead. So, whereas 27 is not
quotable, 69 is because it is the ASCII value for the capital letter "E". So,
instead of LPRINT CHR$(27);CHR$(69) you could, if you prefer, use
LPRINT CHR$(27);"E" which sends exactly the same codes to a printer.
Where a code uses 0 and 1 as ON and OFF flags then you can normally
use 48 ("0") and 49 ("1") as alternatives.
Some BASIC language versions in some modes always add a line feed
after LPRINT. If you keep getting extra line spaces then you might try
adding a semi-colon (;) at the end of the LPRINT string, for example,
LPRINT CHR$(27);CHR$(69);
QUICK BASIC has some terrible quirks if sending codes. You might well
find it sending a line feed code in the middle of sending graphic data! If
you get problems with some codes not doing what they should then
instead of LPRINT try instead the following...
The above 'OPEN' line need only be used once at the start of the program
and need not be used before every PRINT #.
The #3 at the end of the 'OPEN' line can be any value from 1 to 15 but you
cannot use the same number as is being used for some other operation
at the same time (eg, if you have opened a file for reading or writing).
"LPT1" or "LPT2" can be used instead of "PRN" but "PRN" works for
both whereas "LPT1" would fail on a system configured for "LPT2"
esc$=CHR$(27)
emph$=esc$+"E"
emphOFF$=esc$+"F"
dubStrike$=esc$+"G"
dubStrikeOFF$=esc$+"H"
bold$=emph$ + dubStrike$
boldOFF$=emphOFF$+dubStrikeOFF$
In the list, variable codes are represented by labels which you need to
replace with actual values (or programming varaibles) when used. For
example, you might substitute 5 for n (depending on what you want to
achieve and what the range of the parameter allows). Where more
explanation is needed an asterisk with a number is shown, eg, *1 and *2.
Details of these are explained at the end of the list.
In the list, lo, hi means a two byte value between 0 and 65535. You
replace lo and hi with the values you want. To calculate lo and hi, take
your original value (example: the length of image data, let's say 700 bytes
long. Divide it by 256 which is 2 and a remainder of 188. hi is the 2 and lo
is the remainder so it would be put in as 188,2 to replace lo,hi when
actually applying any of the code sequences listed below. lo,hi must
never be greater than the graphics mode selected will allow of dots on
one line.
Not all printers will implement all the codes nor is the list complete so
some printers might implement more codes. The list shows the most
commonly-used codes.
These codes will not be effective from many Windows programs (that is,
from the user's point of view) so don't expect Notepad to print wide print
after you have sent the wide code!
Some codes are not implemented immediately but for example after the
next line feed. So if nothing seems to happen it does not necessarily
mean there is a fault. However, if when printing images you do not send
the correct data length, the printer might be expecting more image data
and will treat further codes or even text as more image data. This might
be buffered and the printer will do nothing. Even using 27,64 will not clear
the printer; you might have to switch it off or send enough image data.
8 Back Space
7 Beep or bell
24 Cancel line
www.fidcal.com/printercodes/ 4/14
4/1/13 Epson ESC/P and ESC/P2 Printer Codes
15 Condensed Characters ON
19 Deselect printer
27,71 Double-strike ON
14 Double-width characters ON *6
www.fidcal.com/printercodes/ 5/14
4/1/13 Epson ESC/P and ESC/P2 Printer Codes
27,115,1 Fast/half-tone ON
www.fidcal.com/printercodes/ 6/14
4/1/13 Epson ESC/P and ESC/P2 Printer Codes
27,115,1 Half-tone/fast ON
17 Printer select
19 Printer deselect
17 Select printer
27,83,0 Superscript ON
27,83,1 Subscript ON
27,45,1 Underline ON
lo,hi must not be greater than the dots a line shown because that is the maximum (it can of
course be less)
*2 Alternate Characters. Many printers have an alternate character set that can be switched to.
Typically this might be the same character set as the main one but in italic (sloping) form.
*3 Line space n/216th" (27,74,n) is temporary for that line only and de- faults to previous setting
after a line feed. That is, it clears itself. To set up n/216th" line spacing permanently (until you
clear it with another code) use 27,51,n
*4 Top and Bottom margins: 27,78,n and 27,79 are actually skip perforation ON and OFF. The
printer normally counts DOWN the number of lines left to print on the page (default total normally
66 but can be changed with the Page Length code).
If this skip perforation code is ON then when the printer counts down to 'n' it prints 'n' blank lines.
If you initially line up the top of the paper in line with the print head then you will get no margin at
the top(unless blank lines are included in the text being printed) but 'n' blank lines at the bottom.
To get an equal margin top and bottom you need to either wind down or manually line feed the
paper down half of n lines at the top of the first page (these line feeds can be included in a
program that is printing a document). When the printer tries to print n blank lines at the bottom of
each page it will then only print half at the bottom and half at the start of the next page.
*5 National character set. There are variations in the character set for different countries. For
example, Character 35 is the hash sign "#" in the American selection but a pound sign "" in the
UK. The codes are 27,82,n where n is:
0=USA
1=France
2=Germany
3=UK
4=Denmark 1
5=Sweden
6=Italy
7=Spain 1
www.fidcal.com/printercodes/ 13/14
4/1/13 Epson ESC/P and ESC/P2 Printer Codes
8=Japan
9=Norway
10=Denmark 2
11=Spain 2
12=Latin America
Probably most printers are set for USA by default. Not all printers cover all the countries shown.
The first four are most common.
*6 Wide (enlarged) characters mode using 27,14 is only temporary for that line and is cleared
when printing starts a new line. Likewise 27,20 only cancels one-line wide print. Wide characters
using 27,87,1 are permanent until switched off with code 27,87,0.
*8 Whether codes 27,120,1 will provide Letter Quality (LQ) or Near Letter Quality (NLQ) depends
on your printer. 9-pin printers typically will only give NLQ. Draft quality is simply disabling LQ or
NLQ to print normally.
www.fidcal.com/printercodes/ 14/14