How PCL5 works

How PCL5 works

HP PCL language printer commands provide access to printer features. PCL commands are embedded in the print job, flagged by the "escape" character. When the printer sees the escape character, it knows the following characters will be a command.

There are four general types of HP PCL language commands:

  • Control codes
  • PCL commands
  • HP-GL/2 commands
  • PJL commands

Control Codes
A control code is a character that initiates a printer function, for example Carriage Return (CR), Line Feed (LF), and Form Feed(FF).

HP PCL commands
PCL commands provide access to the printer’s PCL control structure. The PCL structure controls all of the printer’s features except those used for vector graphics, which are controlled by the HP-GL/2 commands.

PCL printer commands consist of two or more characters. The first character is always the ASCII escape character, identified by the Ec symbol. The Ec symbol is a special control code which identifies the subsequent string of characters as a printer command. As the printer monitors incoming data from a computer, it “looks” for this character. When this character appears, the printer reads it and its associated characters as a command to perform and not as data to print.

Note: "printer command" = "escape sequence"

PCL printer commands (other than single-character control codes) are also referred to as escape sequences. The terms printer command and escape sequence are used interchangeably in HP PCL documents.

Once a PCL command sets a parameter, that parameter remains set until that PCL command is repeated with a new value, or the printer is reset to its user default environment. For example, if you send the printer a command to set line spacing to 3 lines/inch, each page prints 3 lines/inch until the printer receives a different Line Spacing command, or the printer is reset.

HP-GL/2 Commands (introduced in PLC5)
HP-GL/2, vector graphic commands are two letter mnemonic codes designed to remind you of the function name (such as IN for Initialize). Following the two letter mnemonic may be one or more parameters, which identify details of how to process the command. For additional information on HP-GL/2 commands, refer to Chapters 17 through 23. in the PCL5 Printer Language Technical Reference Manual.

PJL Commands
Printer Job Language (PJL) commands provide a different type of printer control. Unlike PCL and HP-GL/2, which control the placement of dots on the printed page, PJL supplies job-level control. One of the main features PJL offers is the ability to switch printer languages (personalities) between jobs. For example, applications supporting PJL can print one job using PCL, and then print the next job using PostScript or another printer language, without any operator intervention.

PJL also provides two-way communications with the printer. For example, PJL can request information from the printer such as printer model, configuration, printer status, and job status. PJL also can be used to change the printer’s control panel settings and modify the message displayed on the control panel.

The PJL language is designed to be used by application developers and technical support personnel only.


What the printer sees

Here is an example of a command to print the page in a landscape orientation. 

  • The Escape character signals that the incoming print job has a command for the printer.
  • The lower case L is the Group Character.
  • Setting the "Value Field" to 1 tell the printer this page will be landscape.
  • Finally the O ends the command sequence.

See the PCL5 Technical Reference Manual for a deep dive into the abstraction of putting dots on paper.