ESC commands usage in dot-matrix printer driver

Michael Sweet mike at
Wed Jan 12 08:14:01 PST 2005

Soju_Varghese wrote:
> Hi,
> I want to develop a linux printer driver for dot matrix printer which
> uses the ESC/P commands.I am using cups framework for the printer 
> driver development. From my understanding if I am using the existing
> 9 pin Epson linux driver,the following is the flow. pstops
> ->cupsomatic-> backend. There is no filter driver(use of ESC
> commands) using here, It is directly using the post script and
> sending it to the printer.

No, that isn't correct.

If you are printing a PS file, the flow is:

     pstops -> pstoraster -> rastertoepson -> backend

"pstoraster" is a wrapper script which calls Ghostscript using
the "cups" driver in Ghostscript to create a series of page images
in the CUPS raster format which the rastertoepson filter can read
and convert to ESC/P.

Some other common flows on Linux:

     "text files"

     texttops -> pstops -> pstoraster -> rastertoepson -> backend

     "pdf files"

     pdftops -> pstops -> pstoraster -> rastertoepson -> backend

     "hp-gl/2 files"

     hpgltops -> pstops -> pstoraster -> rastertoepson -> backend

     "image files"

     imagetoraster -> rastertoepson -> backend

The "cupsomatic" and "foomatic" filters are part of the non-CUPS
drivers at (they allow you to use Ghostscript-
based printer drivers with CUPS, and provide wrappers for PS
printers as well)

> If I want to develop a 12 wire dot matrix printer driver,which
> supports raster printing and also resident font prinitng. For 
> graphics printing I can take the 9 pin data and convert it to the 12
> pin data. Corresondingly the ESC commands have to be manipulated. I
> want to know where I can get hold of this ESC commands (for verical
> and horizontal movement of the head)and data so that I can manipulate
> the way in which I want. whether I have to look into
> "rastertoepson.c" provided in the cups and the ppd files  present.I
> am looking into and

Look at for an ESC/P reference manual, and
the manufacturer's resources for information on their specific

That said, the CUPS raster driver framework does not support the
use of resident fonts.  You can create a separate text filter for
printing plain text files (that is pretty easy, and the CUPS book
includes an example for PCL printers) assuming that you don't need
landscape or Unicode text support...

It might be possible to develop a Ghostscript-based driver that
supports mixed text and graphics, however I would advise against
this approach since the gains would be small for a dot-matrix
device and you will spend a very long time developing the driver.

Michael Sweet, Easy Software Products           mike at easysw dot com
Internet Printing and Document Software

More information about the cups mailing list