Using HP PCL5e Printer Escape Sequences

A printer command escape sequence always begins with the escape character (ESC).

The escape sequence is a command that tells the printer to perform a certain function.

It consists of an ESC code (27 decimal or 1B hexadecimal) followed by one or more

printable characters (48 through 126 decimal, 30 through 7E hexadecimal).


Most escape sequence printer commands consist of the ESC code followed by a

character (within the range of 33 through 47 decimal, 21 through 2F hexadecimal), a

group character (within the range of 96 through 126 decimal, 60 through 7E

hexadecimal), a value field, and a terminating character.


The value field specifies a number whose interpretation depends on the command. A

value field is indicated by [#] in the escape sequences. In general, numbers can start

with a plus (+) or minus (-) sign indicating a positive or negative value.


The + or - sign is followed by one or more ASCII numerals followed by a decimal point

(ASCII period) and more numerals. The sign and decimal point can be omitted if not


Value fields without a sign are treated as positive numbers. Value fields without decimal

points are treated as integers. If an integer value is required, fractions are truncated.

Spaces within the value field are ignored.

The terminating characters indicate that the escape sequence command is complete.

The emulation uses characters within the range of 64 through 94 decimal (40 through

5E hexadecimal) as terminators. When escape sequences are combined, group

characters are used instead of terminating characters.

Some escape sequences must be followed by binary data. Usually the number of bytes

of binary data is specified within the command.



Escape Sequences Syntax

The escape sequence syntax includes the lower case letters “l” and “o” that are easily

confused with the numbers one (1) and zero (0). For clarity, the lower case “l” is

italicized ( l ) in the escape sequence descriptions and listings.


If escape sequence does not work correctly, make sure that you did not use a “0" (zero)

or “1" (one) where a letter “o” or “l” is needed.


Note that the spaces shown in the escape sequences should not be included when a

command is sent to the printer. The brackets ([ and ]) used to show value fields or data

are also not part of the escape sequences.


When you see [#] in an escape code sequence, you must supply a parameter value.

Replace the [#] with a decimal or hexadecimal value. When using a quoted string in

BASIC, replace the [#] with an ASCII decimal value or character. In both cases, do not

include the brackets.



ESC % -12345X          Universal exit/start of PJL.

ESC E                          Reset printer to user defaults. All temporary fonts and macros are deleted. Any

                                     remaining data is printed using the user default values.


ESC & l [#]X                       Select [#] of copies (1 to 32,767).

ESC & l [#]U                       Set left (long edge) offset registration in decipoints (1/720") to adjust the

                                     logical page position on the width of the physical page. Both positive and

                                     negative values are accepted.


ESC & l [#] Z                      Set top (short edge) offset registration in decipoints (1/720") to adjust the

                                     logical page position on the length of the page. Both positive and negative

                                     values are accepted.


ESC & l [#] S                     Select simplex or duplex printing mode.

                                     # Printing Mode

                                     0 Simplex.

                                     1 Duplex, Long-Edge Binding.

                                     2 Duplex, Short-Edge Binding.

ESC & a [#] G            Select page side [#] for printing. If duplex printing is not supported, a page eject is performed.


                                    # Page Side

                                    0 Next side is selected.

                                    1 Front side is selected.

                                    2 Back side is selected.


ESC | x [#] J                This command can modify several different job control settings.

          PCL image offset*

          Page mode jog*

              Input tray selection mode*

              Output tray mask

* These settings are persistent, meaning they stay in effect after a power cycle. To change all of these settings back to Standard, execute a "Restore to Factory Defaults" via the OCP or Web. To change a specific setting back to Standard, reenter the command with the Standard value field.


PCL Image Offset


Standard (default).







Use with early versions of MicroPress systems only.




Page Mode Jog


Standard (default).




Enable page mode jog.



When Page Mode Jog is enabled, Job Offset (Jog) enabled, multiple copies selected, and collation is disabled, a jog operation occurs between the printing of pages. For example, if a job prints 10 pages (simplex), 3 copies, with collation off and Page Mode Jog disabled, the output is offset at the end of the job. That is, if two such jobs are printed, the second job is offset from the first. If Page Mode Jog is enabled for this same job, sheet 11 is offset from sheet 10, sheet 21 is offset from sheet 20, and the first sheet of the next job is offset from sheet 30 (the last sheet of this job).




Input Tray Selection Mode


Standard (default).

Setting the tray selection mode with a 10X code makes the mode persistent. The selected mode will be active immediately and it will be reestablished whenever PJL environment values are set to their default values. This happens when:

- PJL mode is entered with a Universal Exit Language

(UEL) command.

- a PJL End of Job (EOJ) command is processed.

- a PJL initialize command is processed.

- the printer is reset to the Factory default from the OCP or





Option 1.


Option 2.


Option 3.


Option 4.


Option 5.


Custom Mapping 6


Custom Mapping 7


Standard (default).

Setting the tray selection mode with a 20X code makes the selected mode active immediately, but it is not persistent. The tray selection mode will revert to the last persistent selection whenever PJL environment values are set to their default values. See the comments above.




Option 1


Option 2


Option 3


Option 4


Option 5


Custom Mapping 6


Custom Mapping 7

NOTE: Refer to "Paper Source" on page 2-12 for input tray option definitions.






Output Tray Mask


Disable auto cascading for Stacker 5




Disable auto cascading for Stacker 6




Disable auto cascading for Stacker 7




Disable auto cascading for Stacker 8




Enable auto cascading for Stacker 5 (default)




Enable auto cascading for Stacker 6 (default)




Enable auto cascading for Stacker 7 (default)




Enable auto cascading for Stacker 8 (default)



Refer to "Output Bin" on page 2-10 for output tray selections. These settings stay in effect until they are changed or the printer is reset.





Paper Size

ESC & l [#] A         

Set physical page size to [#]. A tray with the selected paper size must be installed and selected as a paper source.


Paper Size


Executive (7.25’’ x 10.5’’)




Letter (8.5" x 11")




Legal (8.5" x 14")




Ledger (11" x 17")




Statement (8.5" x 5.5")




A4 (297mm x 210mm)




A3 (297mm x 420mm)




Folio (216mm x 330mm)




JIS B5 (182mm x 257mm)




JIS B4 (257mm x 364mm)




Universal or Custom. Media size must be set to Custom and physical media dimensions must be entered through the operator control panel or SNMP.




Letter SEF (8.5" x 11")




A5 SEF (149mm x 210mm)




A4 SEF (210mm x 297mm)




LetterTab Stock (9" x 11")




A4 Tab Stock (297mm x 225mm)






SuperB (12" x 18")





Page Length

ESC & l [#] P          

Set logical page length to [#] lines. This is an alternate, but not recommended, method for selecting a page length. The page length selected is the smallest logical page length that is greater than the specified number of lines multiplied by the current VMI.





ESC & l [#] O         

Select print orientation (#).


Print Orientation










Reverse portrait.




Reverse landscape.



ESC & a [#] P         


Select print direction [#]. Rotate the logical page coordinates counterclockwise in 90 degree increments from the current logical page orientation.




Do not rotate.




Rotate 90 degrees.




Rotate 180 degrees.




Rotate 270 degrees.



See the attached PDF for more information.


Source:  Ricoh


Article is closed for comments.
Powered by Zendesk