GIMP-Print - ESC/P2 Standard Commands

Go to the first, previous, next, last section, table of contents.

## C.2 Standard commands

ESC/P2 command: `ESC @`
  Reset the printer. Discards any output, ejects the existing page, returns all settings to their default. Always use this before printing a page.

ESC/P2 command: `ESC (G BC=1 ON1`
  Turn on graphics mode. ON should be ``1'` (turn on graphics mode).

ESC/P2 command: `ESC (U BC=1 UNIT1`
  Set basic unit of measurement used by printer. This is expressed in multiples of 1/3600". At 720 DPI, UNIT is ``5'`; at 360 DPI, UNIT is ``10'`.

ESC/P2 command: `ESC (U BC=5 PAGEUNITS1 VUNIT1 HUNIT1 BASEUNIT2`
  Set basic units of measurement used by the printer. PAGEUNIT is the unit of page measurement (for commands that set page dimensions and the like). VUNIT is the unit of vertical measurement (for vertical movement commands). HUNIT is the unit of horizontal movement (for horizontal positioning commands). All of these units are expressed in BASEUNIT, which is in reciprocal inches. Typically, BASEUNIT is ``1440'`. In 720 DPI mode, PAGEUNIT, VUNIT, and HUNIT are all ``2'`; in 1440x720 DPI mode, PAGEUNIT and VUNIT are normally set to ``2'`; HUNIT is set to ``1'`.

ESC/P2 command: `ESC (K BC=2 ZERO1 GRAYMODE1`
  Set color or grayscale mode, on printers supporting an explicit grayscale mode. These printers can be identified because they are advertised as having more black nozzles than nozzles of individual colors. Setting grayscale mode allows use of these extra nozzles for faster printing. GRAYMODE should be ``0'` or ``2'` for color, ``1'` for grayscale. ZERO should always be ``0'`.

ESC/P2 command: `ESC (i BC=1 MICROWEAVE1`
  If MICROWEAVE is ``1'`, use microweave mode. On older printers, this is used to turn on microweave; on newer printers, it prints one row at a time. All printers support this mode. It should only be used at 720 (or 1440x720) DPI. The Epson Stylus Pro series indicates additional modes:
  ``2'`
    "Full-overlap"
  ``3'`
    "Four-pass"
  ``4'`
    "Full-overlap 2"

  Any of these commands can be used with the high four bits set to either ``3'` or ``0'`.

ESC/P2 command: `ESC U DIRECTION1`
  If DIRECTION is ``1'`, print unidirectionally; if ``0'`, print bidirectionally.

ESC/P2 command: `ESC (s BC=1 SPEED1`
  On some older printers, this controls the print head speed. SPEED of ``2'` is 10 inches/sec; SPEED of ``0'` or 1 is 20.

ESC/P2 command: `ESC (e BC=2 ZERO1 DOTSIZE1`
  Choose print dotsize. DOTSIZE can take on various values, depending upon the printer. Almost all printers support ``0'` and ``2'`. Variable dot size printers allow a value of 16. Other than the value of 16, this appears to be ignored at resolutions of 720 DPI and above.

ESC/P2 command: `ESC (C BC=2 PAGELENGTH2`
ESC/P2 command: `ESC (C BC=4 PAGELENGTH4`
  Set the length of the page in "pageunits" (see ``ESC (U'` above). The second form of the command allows setting of longer page lengths on new printers (these happen to be the printers that support variable dot size).

ESC/P2 command: `ESC (c BC=4 TOP2 LENGTH2`
ESC/P2 command: `ESC (c BC=8 TOP4 LENGTH4`
  Set the vertical page margins of the page in "pageunits" (see ``ESC (U'` above). The margins are specified as the top of the page and the length of the page. The second form of the command allows setting of longer page lengths on new printers (these happen to be the printers that support variable dot size).

ESC/P2 command: `ESC (S BC=8 WIDTH4 LENGTH4`
  Set the width and length of the printed page region in "pageunits" (see ``ESC (U'` above).

ESC/P2 command: `ESC (v BC=2 ADVANCE2`
ESC/P2 command: `ESC (v BC=4 ADVANCE4`
  Feed vertically ADVANCE "vertical units" (see ``ESC (U'` above) from the current print head position.

ESC/P2 command: `ESC (V BC=2 ADVANCE2`
ESC/P2 command: `ESC (V BC=4 ADVANCE4`
  Feed vertically ADVANCE "vertical units" (see ``ESC (U'` above) from the top margin.

ESC/P2 command: `ESC ($ BC=4 OFFSET4`
  Set horizontal position to OFFSET from the left margin. This command operates on printers of the 740 class and newer (all printers with variable dot size).

ESC/P2 command: `ESC $ OFFSET2`
  Set horizontal position to OFFSET from the left margin. This command operates on printers of the 740 class and newer (all printers with variable dot size).

ESC/P2 command: `ESC (\ BC=4 UNITS2 OFFSET2`
  Set horizontal position to OFFSET from the previous print head position, measured in UNITS. UNITS is measured in inverse inches, and should be set to 1440 in all cases. This operates on all 1440 dpi printers that do not support variable dot size.

ESC/P2 command: `ESC (/ BC=4 OFFSET4`
  Set horizontal position to OFFSET from the previous print head position, measured in "horizontal units" (see ``ESC (U'` above). This operates on all variable dot size printers.

ESC/P2 command: `ESC \ OFFSET2`
  Set horizontal position to OFFSET from the previous print head position, measured in basic unit of measurement (see ``ESC (U'` above). This is used on all 720 dpi printers, and can also be used on 1440 dpi printers in lower resolutions to save a few bytes. Note that OFFSET may be negative. The range of values for this command is between ``-16384'` and ``16383'`.

ESC/P2 command: `ESC r COLOR1`
ESC/P2 command: `ESC (r BC=2 DENSITY1 COLOR1`
  Set the ink color. The first form is used on four-color printers; the second on six-color printers. DENSITY is ``0'` for dark inks, ``1'` for light. COLOR is
  ``0'`
    black
  ``1'`
    magenta
  ``2'`
    cyan
  ``4'`
    yellow

  This command is not used on variable dot size printers in softweave mode.

ESC/P2 command: `ESC . COMPRESS1 VSEP1 HSEP1 LINES1 WIDTH2 data...`
  Print data. COMPRESS signifies the compression mode:
  ``0'`
    no compression
  ``1'`
    TIFF compression (incorrectly documented as "run length encoded")
  ``2'`
    TIFF compression with a special command set.

  VSEP depends upon resolution and printer type. At 360 DPI, it is always ``10'`. At 720 DPI, it is normally ``5'`5. On the ESC 600, it is ``40'` (@math{8 * 5}). On some other printers, it varies.

  HSEP1 is ``10'` at 360 DPI and ``5'` at 720 or 1440 DPI (1440 DPI cannot be printed in one pass; it is printed in two passes, with the dots separated in each pass by 1/720").

  LINES is the number of lines to be printed. It should be ``1'` in microweave and 360 DPI. At 720 DPI softweave, it should be the number of lines to be actually printed.

  WIDTH is the number of pixels to be printed in each row. Following this command, a carriage return (``13'` decimal, ``0A'` hex) should be output to return the print head position to the left margin.

  The basic data format is a string of bytes, with data from left to right on the page. Within each byte, the highest bit is first.

  The TIFF compression is implemented as one count byte followed by one or more data bytes. There are two cases:

  1. If the count byte is ``128'` or less, it is followed by @math{[count] + 1} data bytes. So if the count byte is ``0'`, it is followed by 1 data byte; if it is ``128'`, it is followed by 129 data bytes.
  2. If the count byte is greater than 128, it is followed by one byte. This byte is repeated (257 - [count]) times. So if [count] is 129, the next byte is treated as though it were repeated 128 times; if [count] is 255, it is treated as though it were repeated twice.

ESC/P2 command: `ESC i COLOR1 COMPRESS1 BITS1 BYTES2 LINES2 data...`
  Print data in the newer printers (that support variable dot size), and Stylus Pro models.

  COLOR is the color:

  ``0'`
    black
  ``1'`
    magenta
  ``2'`
    cyan
  ``4'`
    yellow
  ``17'`
    light magenta
  ``18'`
    light cyan

  COMPRESS signifies the compression mode:

  ``0'`
    no compression
  ``1'`
    TIFF compression (incorrectly documented as "run length encoded")
  ``2'`
    TIFF compression with a special command set.

  BITS is the number of bits per pixel.

  BYTES is the number of bytes wide for each row (@math{ceiling(BITS * width_of_row, 8)}). Note that this is different from the ``ESC .'` command above.

  LINES is the number of lines to be printed. This command is the only way to get variable dot size printing. In variable dot mode, the size of the dots increases as the value (``1'`, ``2'`, or ``3'`) increases.

ESC/P2 command: `ESC (D BC=4 BASE2 VERTICAL1 HORIZONTAL1`
  Set printer horizontal and vertical spacing. It only applies to variable dot size printers in softweave mode (and possibly other high end printers).

  BASE is the base unit for this command; it must be ``14400'`.

  VERTICAL is the distance in these units between printed rows; it should be (@math{separation_in_nozzles * BASE / 720}).

  HORIZONTAL is the horizontal separation between dots in a row. Depending upon the printer, this should be either (@math{14400 / 720}) or (@math{14400 / 360}). The Stylus Pro 9000 manual suggests that the settings should match the chosen resolution, but that is apparently not the case (or not always the case) on other printers.

ESC/P2 command: `ESC (R BC=8 00 R E M O T E 1`
  Enters "remote mode". This is a special, undocumented command set that is used to set up various printer options, such as paper feed tray, and perform utility functions such as head cleaning and alignment. It does not appear that anything here is actually required to make the printer print. Our best understanding of what is in a remote command sequence is described in a separate section below.

ESC/P2 command: `ESC 01 @EJL [sp] ID\r\n`
  Return the printer ID. This is considered a remote mode command, although the syntax is that of a conventional command. This returns the following information:

      @EJL ID\r
      MFG:EPSON;
      CMD:ESCPL2,BDC;
      MDL:[printer model];
      CLS:PRINTER;
      DES:EPSON [printer model];
      \f

After all data has been sent, a form feed byte should be sent.

All newer Epson printers (STC 440, STP 750) require the following command to be sent at least once to enable printing at all. This command specifically takes the printer out of the Epson packet mode communication protocol (whatever that is) and enables normal data transfer. Sending it multiple times is is not harmful, so it is normally sent at the beginning of each job:

    ESC 01@EJL[space]1284.4[newline]@EJL[space][space][space][space]
    [space][newline]ESC@

The proper sequence of initialization commands is:

    magic command
    ESC
    remote mode if needed
    ESC (G
    ESC (U
    ESC (K (if appropriate)
    ESC (i
    ESC U (if needed)
    ESC (s (if appropriate)
    ESC (e
    ESC (C
    ESC (c
    ESC (S
    ESC (D (if needed)
    ESC (V (optional -- this can be accomplished with ESC (v)

For printing, the proper sequence is:

    ESC (v

and repeat for each color:

    ESC ($ or ESC (\ or ESC \
    ESC (r or ESC r (if needed--not used with `ESC i' and not needed if the color
    has not changed from the previous printed line)
    ESC . or ESC i  ...data... [return] (0A hex)

To terminate a page:

    [formfeed] (0C hex)
    ESC @

Go to the first, previous, next, last section, table of contents.