PCL levels 1 to 5 share one command syntax, defined in HP’s PCL 5 Printer
Language Technical Reference Manual: printable text mixed with commands that start
with the Escape byte (0x1B, written Esc here). PCL 6’s PCL XL is a different,
binary language: see PCL XL. Jobs of
either kind are usually wrapped in Printer Job Language (PJL).
Two-character commands
Esc followed by one character from 0x30 to 0x7E. The main ones:
| Command | Bytes | Meaning |
|---|---|---|
Esc E | 1B 45 | Printer reset: prints any partial page and restores the user defaults. Jobs start and end with it. |
Esc 9 | 1B 39 | Clear horizontal margins. |
Esc = | 1B 3D | Half line feed. |
Esc Y | 1B 59 | Display functions on: print control codes instead of acting on them. |
Esc Z | 1B 5A | Display functions off. |
Esc z | 1B 7A | Print the self-test page. |
Parameterised commands
Esc & l 1 O
1B 26 6C 31 4F
│ │ │ └ termination character (upper case: ends the command)
│ │ └ value
│ └ group character
└ parameterised character
| Part | Range | Meaning |
|---|---|---|
| Parameterised character | 0x21–0x2F (! " # $ % & ' ( ) * + , - . /) | Says a parameterised command follows. &, *, (, ) and % are the common ones. |
| Group character | 0x60–0x7E (lower case letters and `) | The command group, such as l for page control. Some commands have none (Esc(8U). |
| Value | digits, optional + or -, optional decimal point | Values range from −32767 to 65535; some commands take four decimal places. A missing value counts as 0. |
| Parameter character | 0x60–0x7E (lower case) | Ends this parameter but not the command: another value and letter of the same group follow. |
| Termination character | 0x40–0x5E (upper case and @ [ \ ] ^) | Ends the command. |
Commands with the same parameterised and group characters can be combined by
writing the termination letter in lower case and continuing: Esc&l1o2A
means Esc&l1O then Esc&l2A. Some commands are followed
by binary data whose length is the value, such as Esc*b100W and 100
bytes of raster data, or Esc)s64W and a 64-byte font header.
Control codes
| Code | Byte | Action |
|---|---|---|
| BS | 08 | Back one character. |
| HT | 09 | Next tab stop: the left margin and every 8th column after it; ignored when the HMI is 0. |
| LF | 0A | Line feed (and carriage return, depending on line termination mode). |
| FF | 0C | Form feed: print the page. |
| CR | 0D | Carriage return. |
| SO | 0E | Shift out: use the secondary font. |
| SI | 0F | Shift in: use the primary font. |
| SP | 20 | Space, by the current horizontal motion index. |
| ESC | 1B | Starts a command. |
Bytes that would otherwise be control codes can be printed as characters with
Esc&pnX (transparent print data) or in display
functions mode (Esc Y).
Printer Job Language
PJL lets a job choose the printer language and settings, and lets the
printer report status. A PJL job starts with the Universal Exit Language command
Esc%-12345X (1B 25 2D 31 32 33 34 35 58), which also returns
any printer to PJL from whatever language it is in, followed by lines starting
@PJL and ending in LF or CR LF.
<Esc>%-12345X@PJL JOB NAME="Report"
@PJL SET DUPLEX=ON
@PJL SET PAPER=A4
@PJL ENTER LANGUAGE=PCL
<Esc>E … PCL job … <Esc>E
<Esc>%-12345X@PJL EOJ NAME="Report"
<Esc>%-12345X
| Command | Meaning |
|---|---|
@PJL | A blank command, often the first line. |
@PJL COMMENT text | A comment. |
@PJL JOB [NAME="…"] [START=n] [END=n] [PASSWORD=n] [DISPLAY="…"] | Starts a job; START and END choose which pages print (1 to 2,147,483,647). |
@PJL EOJ [NAME="…"] | Ends a job. |
@PJL ENTER LANGUAGE=lang | Switches to a personality: PCL, POSTSCRIPT, ESCP or another the printer supports (@PJL INFO CONFIG lists them). PCL XL is entered as PCLXL, as Ghostscript’s PCL XL driver writes it. The data in that language follows. |
@PJL SET variable=value | Sets an environment variable for this job, such as COPIES, DUPLEX, BINDING, PAPER, ORIENTATION, RESOLUTION, ECONOMODE, RET, INTRAY1, OUTBIN, RENDERMODE, HOLD, USERNAME. |
@PJL DEFAULT variable=value | Changes a default kept after the job. |
@PJL INITIALIZE, @PJL RESET | Restore factory or user defaults. |
@PJL INQUIRE, @PJL DINQUIRE, @PJL INFO category | Ask for a value, its default, or information (ID, CONFIG, STATUS, VARIABLES, USTATUS, MEMORY, PAGECOUNT…). |
@PJL ECHO, @PJL USTATUS, @PJL USTATUSOFF | Status reporting. |
@PJL RDYMSG, @PJL OPMSG, @PJL STMSG | Messages on the front panel. |
@PJL FSINIT, FSDIRLIST, FSUPLOAD, FSDOWNLOAD, FSDELETE, FSMKDIR, FSQUERY, FSAPPEND | The printer’s file system. |
Vendors add their own variables, sometimes prefixed (@PJL SET LPARM:PCL
for language-specific settings such as FONTSOURCE and
SYMSET).
Sources
- HP, PCL 5 Printer Language Technical Reference Manual, part I (bpl13210), chapter 1 (“Syntax of Escape Sequences”) and chapter 6 (control codes)
- HP, Printer Job Language Technical Reference Manual (bpl13208, 2003) and its addendum (bpl13207) – PJL commands, the ENTER personalities, variables and INFO categories
- Ghostscript gdevpxut.c – the
ENTER LANGUAGE = PCLXLheader its PCL XL driver writes