Updated May 22 2003
PCL5e Control Codes and Escape Sequences
PCL or Printer Command Language, is HP's implementation of commands for
controlling printers. These are commands and escape sequences that
are embedded into the print data. There are three types of
commands. Control codes, two-character escape sequences, and
parameterized escape sequences.
When you need to use a control code in you're document, replace
<code> with the hex value from the ASCII table
Supported control codes are
<BS> BackSpace - move the cursor one space to
<HT> Horizontal Tab - move the cursor to the right
the the next tab stop
<LF> Line Feed - move the cursor down one line
<FF> Form Feed - eject the current page
<CR> Carriage Return - move the cursor to the
<SO> Shift Out - call the secondary font
<SI> Shift In - return to the primary font
<ESC> ESCape - beginning of an escape sequence
<SP> SPace - move the cursor one space to the
All escape sequences begin with <ESC> or hex 1B.
Two-characters Escape Sequence
A two-character escape sequence would be ESC X, where X defines what action is to take
<ESC>E (1Bh 45h) This is the PCL reset. All PCL jobs
should begin and end with this.
<ESC>9 (1Bh 39h) This resets the left and right margins to
Parameterized Escape Sequence
The majority of the escape sequences will be in this format.
Where X, the parameterized character, indicates that it is a
parameterized escape sequence
Where Y, the group character, specifies the group type of control being
Where # is the value field
Where Z, the termination character, specifies the parameter to which
the value field applies - also terminates the escape sequence.
<ESC>(s0P This command will set the primary font spacing to
A list of all supported control codes, two-character escape sequences,
and parameterized escape sequences are listed in appendix A of the HP
PCL 5 Comparison Guide.
Basic PCL5e example
This is a very basic example. We send the PCL reset at the
beginning, then the text to be printed, and lastly the PCL reset to say
we are done.
This will print "Hello World" on a page using the setting that are
defined in the printer settings under PCL setup. If we wanted to
change one of these settings temporarily we can embed a PCL escape
sequence in the data. For example the default pitch is 10cpi
(characters per inch) and just for this job we would like 12cpi.
The above would change to:
<ESC>E<ESC>(s12HHello World<ESC>E The
last escape sets to pitch(well everything) back to default.
Well, you ask, how do I enter this stuff into a file to send to the