Chapter 16. Printer configuration

Table of Contents
16.1. Introduction
16.2. Preparations
16.3. Configuration
16.4. Access control
16.5. Ghostscript paper size

16.1. Introduction

GNU/Linux supports a large share of the available USB, parallel and network printers. Slackware Linux provides two printing systems, CUPS (Common UNIX Printing System) and LPRNG (LPR Next Generation). This chapter covers the CUPS system.

Independent of which printing system you are going to use, it is a good idea to install some printer filter collections. These can be found in the "ap" disk set. If you want to have support for most printers, make sure the following packages are installed:


a2ps
enscript
espgs
gimp-print
gnu-gs-fonts
hpijs
ifhp
    

Both printing systems have their own advantages and disadvantages. If you do not have much experience with configuring printers under GNU/Linux, it is a good idea to use CUPS, because CUPS provides a comfortable web interface which can be accessed through a web browser.

16.2. Preparations

To be able to use CUPS the "cups" package from the "a" disk set has to be installed. After the installation CUPS can be started automatically during each system boot by making /etc/rc.d/rc.cups executable. This can be done with the following command:


# chmod a+x /etc/rc.d/rc.cups
    

After restarting the system CUPS will also be restarted automatically. You can start CUPS on a running system by executing the following command:


# /etc/rc.d/rc.cups start
    

16.3. Configuration

CUPS can be configured via a web interface. The configuration interface can be accessed with a web browser at the following URL: http://localhost:631/. Some parts of the web interface require that you authenticate yourself. If an authentication window pops up you can enter "root" as the user name, and fill in the root account password.

A printer can be added to the CUPS configuration by clicking on "Administrate", and clicking on the "Add Printer" button after that. The web interface will ask for three options:

You can proceed by clicking the "Continue" button. On the next page you can configure how the printer is connected. If you have an USB printer which is turned on, the web interface will show the name of the printer next to the USB port that is used. After configuring the printer port you can select the printer brand and model. After that the printer configuration is finished, and the printer will be added to the CUPS configuration.

An overview of the configured printers can be found on the "Printers" page. On this page you can also do some printer operations. For example, "Print Test Page" can be used to check the printer configuration by printing a test page.

16.4. Access control

The CUPS printing system provides a web configuration interface, and remote printer access through the Internet Printing Protocol (IPP). The CUPS configuration files allow you to configure fine-grained access control to printers. By default access to printers is limited to localhost (127.0.0.1).

You can refine access control in the central CUPS daemon configuration file, /etc/cups/cupsd.conf, which has a syntax that is comparable to the Apache configuration file. Access control is configured through Location sections. For example, the default global (IPP root directory) section looks like this:


<Location />
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
</Location>
    

As you can see deny statements are handled first, and then allow statements. In the default configuration access is denied from all hosts, except for 127.0.0.1, localhost. Suppose that you would like to allow hosts from the local network, which uses the 192.168.1.0/24 address space, to use the printers on the system you are configuring CUPS on. In this case you could add the line that is bold:


<Location />
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.1.0/24
</Location>
    

You can refine other locations in the address space by adding additional location sections. Settings for sub-directories override global settings. For example, you could restrict access to the epson printer to the hosts with IP addresses 127.0.0.1 and 192.168.1.203 by adding the following section:


<Location /printers/epson>
Order Deny,Allow
Deny From All
Allow From 127.0.0.1
Allow From 192.168.1.203
</Location>
    

16.5. Ghostscript paper size

Ghostscript is a PostStript and Portable Document Format (PDF) interpreter. Both PostScript and PDF are languages that describe data that can be printed. Ghostscript is used to convert PostScript and PDF to raster formats that can be displayed on the screen or printed. Most UNIX programs output PostScript, the CUPS spooler uses GhostScript to convert this PostScript to rasterized format that a particular printer understands.

There are some Ghostscript configuration settings that may be useful to change in some situations. This section describes how you can change the default paper size that Ghostscript uses.

Note

Some higher-end printers can directly interpret PostScript. Rasterization is not needed for these printers.

By default Ghostscript uses US letter paper as the default paper size. The paper size is configured in /usr/share/ghostscript/x.xx/lib/gs_init.ps, in which x.xx should be replaced by the Ghostscript version number. Not far after the beginning of the file there are two lines that are commented out with a percent (%) sign, that look like this:


% Optionally choose a default paper size other than U.S. letter.
% (a4) /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse
    

You can change the Ghostscript configuration to use A4 as the default paper size by removing the percent sign and space that are at the start of the second line, changing it to:


% Optionally choose a default paper size other than U.S. letter.
(a4) /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse
    

It is also possible to use another paper size than Letter or A4 by replacing a4 in the example above with the paper size you want to use. For example, you could set the default paper size to US Legal with:


% Optionally choose a default paper size other than U.S. letter.
(legal) /PAPERSIZE where { pop pop } { /PAPERSIZE exch def } ifelse
    

It is also possible to set the paper size per invocation of Ghostscript by using the -sPAPERSIZE=size parameter of the gs command. For example, you could use add -sPAPERSIZE=a4 parameter when you start gs to use A4 as the paper size for an invocation of Ghostscript.

An overview of supported paper sizes can be found in the gs_statd.ps, that can be found in the same directory as gs_init.ps.