The commands below are those of PCL 5 as found in HP LaserJet printers, written as
Esc plus characters (see escape
sequences); # stands for the value. Units: a decipoint is 1/720 inch,
and a PCL unit is 1/300 inch unless set otherwise with Esc&u#D.
Values are those of HP’s PCL 5 Printer Language Technical Reference Manual;
values marked † are listed only in HP’s PCL 5 Comparison Guide for later
printers. Colour commands are from HP’s PCL 5 Color Technical Reference
Manual. Printer models support different subsets; the comparison guide’s feature
support matrix says which.
Job control
| Command | Meaning and values |
|---|---|
Esc%-12345X | Universal Exit Language: leave PCL for PJL. |
Esc E | Reset. |
Esc&l#X | Number of copies, 1–32767. |
Esc&l#S | Simplex or duplex: 0 simplex, 1 duplex long-edge binding, 2 duplex short-edge. |
Esc&a#G | Duplex page side: 0 next side, 1 front, 2 back. |
Esc&l#U, Esc&l#Z | Left and top offset registration, in decipoints. |
Esc&l1T | Job separation (offset the output). |
Esc&l#G | Output bin: 1 upper, 2 lower (rear). † 0 automatic, 1–3 destination trays 1 to 3. |
Esc&u#D | Unit of measure: PCL units per inch (96, 100, 120, 144, 150, 160, 180, 200, 225, 240, 288, 300, 360, 400, 450, 480, 600, 720, 800, 900, 1200, 1440, 1800, 2400, 3600, 7200). |
Page control
| Command | Meaning and values |
|---|---|
Esc&l#H | Paper source: 0 print the current page (source unchanged), 1 printer-specific tray, 2 manual paper feed, 3 manual envelope feed, 4 lower tray, 5 optional source, 6 envelope feeder. † 7 auto select, 8 tray 1, 20–39 high-capacity input trays 2–21. |
Esc&l#A | Page size: 1 Executive, 2 Letter, 3 Legal, 6 Ledger, 26 A4, 27 A3, 80 Monarch envelope, 81 Com-10 envelope, 90 International DL envelope, 91 International C5 envelope, 100 International B5 envelope. † 25 A5, 45 JIS B5, 46 JIS B4, 71 Hagaki postcard, 72 Oufuku-Hagaki postcard, 101 custom. |
Esc&l#M | † Media type: 0 plain paper, 1 bond, 2 special paper, 3 glossy film, 4 transparency film. Later printers select paper by name instead with Esc&n#Wdname (for example Esc&n6WdPlain; # is the name’s length plus 1). |
Esc&l#O | Orientation: 0 portrait, 1 landscape, 2 reverse portrait, 3 reverse landscape. |
Esc&a#P | Print direction: 0, 90, 180 or 270 degrees counter-clockwise, for text. |
Esc&l#P | Page length, in lines. Named in the PCL 5 Technical Reference (under VMI): if it follows a VMI change the physical page size is recalculated, so the printer may ask for a different paper size. Its value range is not given in the manual text read here. |
Esc&l#E | Top margin, in lines. |
Esc&l#F | Text length, in lines. |
Esc&a#L, Esc&a#M | Left and right margin, in columns. |
Esc&l#L | Perforation skip: 0 off, 1 on. |
Esc&k#H | Horizontal motion index, in 1/120 inch. |
Esc&l#C | Vertical motion index, in 1/48 inch. |
Esc&l#D | Line spacing in lines per inch: 1, 2, 3, 4, 6 (default), 8, 12, 16, 24 or 48; 0 is also accepted. |
Esc&k#G | Line termination: 0 CR=CR LF=LF FF=FF, 1 CR=CR+LF, 2 LF=CR+LF FF=CR+FF, 3 all three. |
Esc&s#C | End-of-line wrap: 0 on, 1 off. |
Esc*o#Q | † Print quality: −1 EconoFast, 0 normal, 1 best (presentation graphics). |
Cursor positioning
| Command | Meaning |
|---|---|
Esc&a#R, Esc&a#C | Vertical and horizontal position in rows and columns; a sign makes it relative. |
Esc&a#V, Esc&a#H | Vertical and horizontal position in decipoints. |
Esc*p#Y, Esc*p#X | Vertical and horizontal position in PCL units. |
Esc&f#S | Push (0) or pop (1) the cursor position, up to 20 deep. |
Fonts
A font is chosen by its characteristics, in priority order. (
sets the primary font and ) the secondary, with the same values.
| Command | Meaning and values |
|---|---|
Esc(#letter | Symbol set, such as Esc(8U Roman-8 (the default), Esc(0N ISO 8859-1 Latin 1, Esc(0U ISO 6 ASCII, Esc(1U Legal, Esc(10U PC-8, Esc(19U Windows 3.1 Latin 1, Esc(1F ISO 69 French, Esc(0Y 3 of 9 barcode. The full list is appendix C of the comparison guide. In font headers and the symbol set ID code the ID is packed as number × 32 + (letter code − 64), so 0U is 21. |
Esc(s#P | Spacing: 0 fixed, 1 proportional. |
Esc(s#H | Pitch, characters per inch (fixed fonts). |
Esc(s#V | Height in points (proportional fonts). |
Esc(s#S | Style, 0–32767, combining posture, width and structure. Common values (table 8-1): 0 upright solid, 1 italic, 4 condensed, 5 condensed italic, 8 compressed (extra condensed), 24 expanded, 32 outline, 64 inline, 128 shadowed, 160 outline shadowed. |
Esc(s#B | Stroke weight, −7 (ultra thin) to 7 (ultra black); 0 medium, 3 bold. |
Esc(s#T | Typeface number, such as 4099 Courier, 4101 CG Times, 4148 Univers, 16602 Arial, 16901 Times New Roman. |
Esc(#X | Select a font by its ID. |
Esc(3@ | Select the default font. |
Esc&d#D, Esc&d@ | Underline on (0 fixed, 3 floating), off. |
Esc&p#X | Transparent print data: the next # bytes are printed as characters. |
Esc&t#P | † Text parsing method: 0 or 1 every code is one byte; 21 bytes 0x21–0xFF start a two-byte character (JIS X 0208, GB 2312, KS C 5601 seven-bit); 31 bytes 0x81–0x9F and 0xE0–0xFC start one (Shift-JIS); 38 bytes 0x80–0xFF start one. |
Font and symbol set downloading
| Command | Meaning |
|---|---|
Esc*c#D | Font ID for the next font commands. |
Esc*c#E | Character code for the next character download. |
Esc*c#F | Font control: 0 delete all, 1 delete temporary, 2 delete font ID, 3 delete character, 4 make temporary, 5 make permanent, 6 copy the current font to the font ID. |
Esc)s#W | Font header: # bytes follow (bitmap, Intellifont or TrueType header, type given in its first bytes). |
Esc(s#W | Character descriptor and data: # bytes follow. |
Esc*c#R, Esc(f#W, Esc*c#S | Symbol set ID, user-defined symbol set data, symbol set control. |
Raster graphics
| Command | Meaning and values |
|---|---|
Esc*t#R | Raster resolution in dots per inch: 75 (default), 100, 150, 200, 300, 600; send before starting raster graphics. |
Esc*r#F | Presentation: 0 in the orientation of the logical page, 3 (default) along the width of the physical page. |
Esc*r#S, Esc*r#T | Source raster width and height, in pixels. |
Esc*t#H, Esc*t#V | Destination width and height in decipoints, for raster scaling (colour printers). |
Esc*r#A | Start raster graphics: 0 at the default left graphics margin (X = 0), 1 at the current cursor; 2 and 3 are the same with raster scaling on (colour printers). |
Esc*b#M | Compression: 0 unencoded, 1 run-length (count and byte pairs), 2 TIFF revision 4.0 (PackBits), 3 delta row, 5 adaptive (several rows in one block). Other values are ignored. |
Esc*b#W | Transfer raster data: # bytes of one row follow (or a block, with method 5). |
Esc*b#V | Transfer one plane of a row, # bytes, for planar colour data; the last plane of the row is sent with Esc*b#W. |
Esc*b#Y | Raster Y offset: move down # raster lines (0–32767), only in raster mode. |
Esc*rB, Esc*rC | End raster graphics. Esc*rC also zeroes the seed row, moves below the raster area, sets compression to 0 and the left graphics margin to 0. |
Rectangles, patterns and print model
| Command | Meaning and values |
|---|---|
Esc*c#A, Esc*c#B | Rectangle width and height in PCL units. |
Esc*c#H, Esc*c#V | Rectangle width and height in decipoints. |
Esc*c#G | Pattern (area fill) ID: for shading, a percentage 1–100 rendered in eight levels (1–2, 3–10, 11–20, 21–35, 36–55, 56–80, 81–99, 100); for cross-hatch, one of six predefined patterns 1–6; or the ID of a user-defined pattern. |
Esc*c#P | Fill the rectangle: 0 black, 1 white, 2 shading, 3 cross-hatch, 4 user pattern, 5 current pattern. |
Esc*v#T | Current pattern: 0 solid black, 1 solid white, 2 shading, 3 cross-hatch, 4 user-defined. |
Esc*v#N, Esc*v#O | Source transparency and pattern transparency: 0 transparent, 1 opaque. |
Esc*c#W | User-defined pattern: # bytes of pattern data follow. |
Esc*c#Q | Pattern control: 0 delete all, 1 delete temporary, 2 delete the last ID, 4 make it temporary, 5 make it permanent. |
Esc*p#R | Set the pattern reference point to the cursor: 0 patterns rotate with the print direction, 1 they stay fixed. |
Esc*l#O | Logical operation: a raster operation (ROP3) code 0–255 combining source, texture and destination; default 252 (TSo). |
Esc*l#R | Pixel placement: 0 grid intersection (default), 1 grid centred. |
How the logical operation and the transparency modes combine
The source is whatever is being printed (characters, a raster image, a rule or rectangle, an HP-GL/2 primitive), the destination is what the page holds, the texture is the foreground colour with the current pattern. The ROP3 code is read in RGB space, where white is 1 and black 0, so
ORing a white object with a black one gives white; the least significant bit of the code is the result for black, the most significant for white (252 is TSo, texture OR source). A code that was written for CMY is made by inverting the bits and reversing their order. The code maps to the Microsoft ROP3
codes; Esc*l#O and HP-GL/2’s MC share one value, and the last one sent applies to both languages.
A “white” pixel of an RGB source or pattern has all three primaries 255 (in CMY, 0); white dots the dithering adds are not subject to the transparency modes. The table 5-4 codes are right only if both modes are opaque (Esc*v1N and Esc*v1O); with a transparent mode (the default), these
cases apply, with “Src” and “Pattern” the opacity of the source and pattern pixel (all ones unless the mode is transparent and the pixel is white), T = ROP3(D, S, texture) and D the destination:
| Source | Pattern | Result |
|---|---|---|
| opaque | opaque | T |
| opaque | transparent | (T and Pattern) or (D and not Pattern) |
| transparent | opaque | (T and Src) or (D and not Src) |
| transparent | transparent | (T and Src and Pattern) or (D and not Src) or (D and not Pattern) |
The manual’s case 2 and 3 formulas are worded so that the opacity masks read as above; the formulas and its prose (white pixels are the transparent ones) agree on that reading. For a rectangular area fill the source is the whole rectangle, solid black, so the source transparency has no effect; the pattern
transparency decides whether the white pixels of a shading, cross-hatch, user-defined or current pattern reach the page, and a white fill (Esc*c1P) erases whatever lies under it whatever the mode. The Print Model also says to restore Esc*v0T, Esc*v0N and Esc*v0O after
the effect.
Colour (PCL 5c)
| Command | Meaning and values |
|---|---|
Esc*r#U | Simple colour: 1 single-plane black palette (default), 3 three-plane device RGB palette, −3 three-plane device CMY palette. |
Esc*v#W | Configure image data: 6 bytes (short form) or more follow. Byte 0 colour space: 0 device RGB, 1 device CMY, 2 sRGB. Byte 1 pixel encoding: 0 indexed by plane (1–8 bits per index), 1 indexed by pixel (1, 2, 4 or 8), 2 direct by plane (1 bit per component), 3 direct by pixel (8 bits per component). Byte 2 bits per index; bytes 3–5 bits per component. |
Esc*v#A, Esc*v#B, Esc*v#C, Esc*v#I | Colour components 1, 2 and 3, then assign them to palette index #. |
Esc*v#S | Foreground colour: palette index. |
Esc*p#P | Push (0) or pop (1) the palette. |
Esc&p#S, Esc&p#I, Esc&p#C | Palette select, palette ID, palette control. |
Esc*t#J | Render algorithm: 0 continuous tone detail, 3 device best dither (default), 15 continuous tone smooth, 18 continuous tone basic, on HP colour LaserJets; other printers accept other ranges up to 19 (comparison guide). |
Esc*t#I, Esc*l#W, Esc*m#W | Gamma correction, colour lookup tables, download dither matrix. |
Macros
| Command | Meaning and values |
|---|---|
Esc&f#Y | Macro ID. |
Esc&f#X | Macro control: 0 start definition, 1 stop definition, 2 execute, 3 call, 4 enable overlay (run at the end of every page), 5 disable overlay, 6 delete all, 7 delete temporary, 8 delete macro ID, 9 make temporary, 10 make permanent. |
HP-GL/2 inside PCL
| Command | Meaning |
|---|---|
Esc*c#X, Esc*c#Y | Picture frame width and height, in decipoints (0–32767); setting them puts P1 and P2 at the frame’s corners. |
Esc*c0T | Set the picture frame anchor point to the cursor. |
Esc*c#K, Esc*c#L | HP-GL/2 plot horizontal and vertical size, in inches. |
Esc%#B | Enter HP-GL/2: 0 previous pen position, 1 current cursor. |
Esc%#A | Return to PCL from HP-GL/2: 0 cursor at the previous PCL position, 1 at the current HP-GL/2 pen position. Even values act as 0 and odd as 1, for both commands. |
Status readback and other commands
| Command | Meaning |
|---|---|
Esc*s#T, Esc*s#U, Esc*s#I, Esc*s#X, Esc*s#M | Status readback: location type (0 invalid, 1 currently selected, 2 all, 3 internal, 4 downloaded, 5 cartridge, 7 user-installable ROM), location unit, inquire entity (0 font, 1 macro, 2 user-defined pattern, 3 symbol set, 4 font extended), echo (−32767 to 32767, returned to the host), free space. |
Esc&r#F | Flush pages: 0 all complete pages, 1 all pages including a partial one. |
Esc&n#W | Alphanumeric ID: # bytes follow, an operation code and a string (media type names, for example). |
What the printer answers
A reply goes back to the port the request came from, is kept in a status buffer until the host reads it (or the printer is switched off, or the resolution, page protection or language personality changes), and replies are made in the order the requests came in. The
number of replies the printer can hold depends on the printer (the manual says a LaserJet 4 holds 5). Every reply starts with the three letters PCL, then CR LF; each further line is CR LF terminated; the reply ends with a form feed (FF, 0x0C):
PCL<CR><LF>
INFO TITLE<CR><LF>
KEYWORD=DATA<CR><LF>
<FF>
A host should read everything between PCL and the form feed and ignore a line whose keyword it does not know, because later printers add keywords. In a reply the escape character is written as the five printable characters <Esc> (the manual’s
wording: “<”, “E”, “s”, “c”, “>”), not as byte 0x1B. The first request of a program should be an Echo with a random number, and the program ignores everything until that number comes back.
| Request | Reply |
|---|---|
Esc*s#X Echo (−32767 to 32767) | PCL then ECHO value: for Esc*s-999X the line is ECHO -999. |
Esc*s1M Free Space | INFO MEMORY, then TOTAL= (all free user memory in bytes, including the largest block) and LARGEST= (the largest continuous block). Any value other than 1 gives ERROR=INVALID UNIT. A job can compare the figures before it downloads data: the printer drops data that does not fit one block. |
Esc*s#T then Esc*s#U then Esc*s#I | The location type (0 invalid, 1 currently selected, 2 all, 3 internal, 4 downloaded, 5 cartridge, 7 user-installable ROM; a value outside 0 to 5 and 7 sets 0; the default and the value after a reset is 0) and unit (for 3 and 5 and 7: 0 all units, 1 the highest priority one, up to the n-th; for 4: 0 all downloaded, 1 temporary, 2 permanent; for types 0 to 2 the unit is ignored; the default and the value after a reset is 0) are kept until changed and may be sent in either order; an invalid pair is only found when the inquiry arrives. The inquiry (0 font, 1 macro, 2 user-defined pattern, 3 symbol set, 4 font extended) makes the reply. |
Inquire fonts, Esc*s0I | INFO FONTS, then for each font a SELECT="…" line holding the escape sequences that would select it, highest priority first (symbol set, spacing, pitch or height, style, weight, typeface). A bitmap font gives its pitch or height (Esc(8U Esc(s0p16.67h8.5v0s0b0T for the Line Printer font); a bound scalable font has two underscores in the place of the size (Esc(s1p__v0s0b16686T); an unbound scalable font has no symbol set in the line and a SYMBOLSETS="0D,0I,0N,…" line follows; a soft font ends its line with its ID (Esc(27X). |
| Inquire fonts at location type 1 (currently selected) | One font, with LOCTYPE= and LOCUNIT= lines after it; the underscores are replaced by the actual size, an unbound font shows the symbol set now bound, and a secondary font’s line uses ) in place of (. |
Inquire font extended, Esc*s4I | INFO FONTS EXTENDED: the font lines as above and two more keywords per font: DEFID= (where the printer keeps it and its internal number: I 21 internal, C or Cn a cartridge, S a permanent soft font, Mn a SIMM, NONE for a temporary soft font, which has none; the number the control panel and PJL use, not the ID of Esc*c#D) and NAME= (the name and treatment in the font list, such as “CG Times Bd”). |
Inquire macros, Esc*s1I | INFO MACROS and IDLIST="1,3,8,29,32". Location type 1 is not valid for macros: ERROR=NONE. |
Inquire patterns, Esc*s2I | INFO PATTERNS and IDLIST="…"; at location type 1 the current pattern’s ID with LOCTYPE= and LOCUNIT=; if the current pattern is one of HP’s own (it has no ID) the reply is ERROR=NONE. |
Inquire symbol sets, Esc*s3I | INFO SYMBOLSETS and IDLIST="0U,2K,8M,8U,11U": the sets that can be bound to unbound scalable fonts at that location. Location type 1 is not valid: ERROR=NONE. |
The four error replies to an inquiry (the only conditions that give one; a syntax error or an uninterpretable command is ignored with no reply; the error line replaces the keyword lines):ERROR=INVALID ENTITY (an entity type out of range, such as Esc*s8I),
ERROR=INVALID LOCATION (the type, the unit or the combination is invalid, or the device is not installed, such as Esc*s5t9U for a cartridge that does not exist), ERROR=NONE (valid, but nothing of that kind is there, or the kind is wrong for the entity) and
ERROR=INTERNAL ERROR (the printer ran out of memory while forming a large reply). Esc&r#F does not answer; it makes the printer stop taking data until the pages it holds are printed (0 only complete pages, 1 also a partial one), which frees memory,
and the manual warns that it slows printing a good deal.
These are output of the printer: a job file contains the requests, and the viewer explains each one in the command list; the replies are never in a file.
Display functions, text path and two-byte text
| Command | Behaviour, from the manuals |
|---|---|
Esc Y, Esc Z | Display functions mode on and off. While it is on, every control code and every escape sequence is printed, not carried out, in the current font and text area, with two exceptions: CR is printed and carried out as CR LF, and Esc Z is printed and carried out. A code the symbol set does not define (most sets define nothing in 0 to 31 and 128 to 159; the PC sets do) prints as a space. Because line feeds are printed rather than carried out, a job turns end-of-line wrap on (Esc&s0C) first, or the text runs off the right margin. Characters 0, 7 to 15 and 27 of a font that has glyphs there (PC-8) can also be printed with Esc&p#X. |
Esc&c0T, Esc&c-1T | Character text path (the LaserJet 4PJ and later; the Comparison Guide). 0: the position moves left to right and a line feed down the page. −1, vertical rotated printing: full-width characters of a large font are rotated 90 degrees counter-clockwise (“on their sides”) and characters with vertical forms (parentheses, small kana, the tilde) use the font’s vertical substitute; one-byte characters are unaffected and the cursor still advances in the horizontal direction. A portrait page of horizontal text becomes a landscape page of vertical text, and Esc&a#P picks the orientation. The rotation point comes from the font’s Vertical Rotation segment (VR, id 22098: a format of 0 and the signed descender, the font’s sTypoDescender; the default descender is −36/256 of the scale factor, bytes 64 and 65 of the header). |
Esc&t#P | Text parsing method. 0 or 1: every code is one byte. 21: codes 0x21 to 0xFF start a two-byte character (JIS X 0208, GB 2312-80, KS C 5601-1992 in seven-bit form). 31: 0x81 to 0x9F and 0xE0 to 0xFC start one (Shift-JIS). 38: 0x80 to 0xFF start one (Big Five, TCA, and the eight-bit forms of KS C 5601 and GB 2312). The following byte is the second byte, whatever its value. The default is 31 when the default symbol set is Windows 3.1J (WIN31J) and 0 otherwise; a printer with GB 2312 as its default set parses GB-style. HP-GL/2 cannot parse two-byte characters. |
| Widths of large fonts | In MS Mincho and MS Gothic every one-byte character is half-width and every two-byte one full-width. ppem = round(resolution × point size / 72); full width = round(ppem × PCL units / resolution); half width = round((ppem / 2) × PCL units / resolution), which need not be exactly half of the full width. When both the character and its galley character are missing the cursor moves by the HMI. |
Sources
- HP, PCL 5 Printer Language Technical Reference Manual, parts I and II (HP part bpl13210 and bpl13211) – syntax, job, page, cursor, font, raster, macro, print model, picture frame and status readback commands
- HP, PCL 5 Printer Language Technical Reference Manual, part I chapter 16 (status readback), part II chapter 24 (display functions mode) and the Comparison Guide’s LaserJet 4PJ section (text parsing method, text path direction, large-font metrics)
- HP, PCL 5 Comparison Guide (bpl13206) – feature support matrix, media type, print quality, text parsing, later paper sizes, sources and bins
- HP, PCL 5 Color Technical Reference Manual (bpl13212) – simple colour, configure image data, render algorithm, compression, raster scaling, logical operations