Adding a new printer

The Developer's Guide to Gutenprint
Prev |  | Next

# Chapter 4. Adding a new printer

This chapter covers adding a new ESCP/2, PCL, or Canon printer. Writing a new driver module is not covered.

The three steps to adding a printer are:

1. Add an entry to `printers.xml`.

2. Add the appropriate code and data to the appropriate driver module.

3. Tune the printer.

Printer information is stored in two places: in `printers.xml` (which contains the list of printer models available to the the upper-level application), and in the appropriate driver file (`print-escp2.c`, `print-pcl.c`, or `print-canon.c`).

# `printers.xml`

`printers.xml` is an XML file that contains very simple printer definitions. A schema may be used to validate the XML (`src/main/gutenprint.xsd`). This is an example definition:

    <printer name="EPSON Stylus Color 1500" driver="escp2-1500">
    <color value="true"/>
    <model value="2"/>
    <gamma value="0.597"/>
    <density value="1.0"/>
    </printer>

There are other tags that may be present. The only ones that are mandatory are `<printer>`, `<color>` and `<model>`. The other optional parameters (`<gamma>` and `<density>` in this case) can be used to adjust control settings. This is probably not the right place for them; the printer drivers themselves should contain this information. There's probably no good reason for anything but gamma and density to be in here. Gamma refers to the printer's gamma factor; density is the desired base ink density for the printer. The Epson driver contains the density information for each printer at each resolution internally. An even better driver would adjust density and possibly even gamma for paper type. All the more reason not to have that information here.

If you really are curious about what tags are permitted, please see the schema. These are the definitions of the tags that do matter:

printdef XML elements

`<family>`

  This defines what driver module this printer uses. The attribute `name` is the name of the family driver to associate the printers with, for example `escp2`, `pcl`, `canon`, `ps` or `raw`. This tag may only contain `<printer>` elements.

`<printer>`

  This starts the definition of a printer. It must contain the attributes `name` and `driver`. `name` should be is the full name of the printer, and must be human readable. `driver` should consist of alphanumerics and hyphens, and be fairly short. `name` is what will appear in the user-visible listing of printers, and may be translated into the user's language, while `driver` is what is actually used to key into the list of printers. It is legal to have multiple printers with the same driver name.

`<color>`

  This tag may not contain any content, but the `value` attribute may be set to `true` or `false`. This indicates that this printer is capable of color, or is not capable of color respectively.

`<model>`

  This defines a model number. This tag may not contain any content, but the `value` attribute may be set to a positive integer. This is passed into the driver, which may do whatever it cares to with it—index into a table, compute on, or whatever. This need not be unique.

Prev | Home | Next
Reporting Bugs |  | The driver file