SDB:Print Settings with CUPS
From openSUSE
Version: 7.2
Contents |
Symptom
You are in charge of the administration of a CUPS printing system and find it very difficult to keep track of the different queue settings. For example:
- Different users obtain different printouts (bad quality printouts or no printouts at all), even though they print identical data through the same queue.
- In the case of network printing, the printouts differ depending on the client machine used, although the user prints identical data through the same queue.
This also applies for the default queue settings: For the default queue setting, there is additionally the environment variable PRINTER. If this environment variable is set to a value other than lp, this setting determines the default queue with highest priority. If PRINTER is set to lp, it is ignored by CUPS. For traditional printing systems, there is an entry in /etc/profile or in /etc/SuSEconfig/profile, which normally sets PRINTER to lp. As this would determine the default queue with highest priority, it would be impossible to set any other default queue with the usual CUPS tools.
Furthermore, it is not possible to transfer the default queue on the CUPS server to the client machines because there could be several CUPS servers that broadcast several default queues to the client machines. For this reason, each client machine must have its own default queue setting. If there is no queue set to be the default queue, the first queue in alphabetical order is used by default.
Cause
The cause is not a bug, but a basic feature of CUPS:
- All users can define different settings for each queue.
- In addition, "root" can define different settings for every single machine (not only on client machines, but also on the CUPS server).
Solution
The solution is simply to know where the settings can be stored and which settings are applied in what situation.
From SuSE Linux 8.1 on, the basic information can be found in the Administration Manual, Chapter "Printer Operation", Section "Command Line Tools for the CUPS Printing System", Subsection "Managing Local Queues".
Example:
For clarification purposes, we have chosen an example of a correct situation that becomes more and more confusing. To keep this example as concise and clear as possible, only command line instructions are used. However, it would make no difference if graphical tools like Kprinter and XPP or the CUPS web front-end were used instead.
Initial state:
The CUPS server is a machine named "sun" to which a color ink jet printer with the queues "mono" and "color" is attached.
Because both queues will be used for the same printer, the same PPD file will be used as basis for the two queues, but with different default values preset for each queue. YaST2, for example, uses this approach when generating different configurations (see the SDB article "Printer Configuration with SuSE Linux 8.1").
The PPD files corresponding to the queues /etc/cups/ppd/mono.ppd and /etc/cups/ppd/color.ppd contain the following possible settings and default values:
*DefaultColors: Gray *Colors Gray ... *Colors Color ... ... *DefaultInkCartridge: Black *InkCartridge Black ... *InkCartridge Color ... ... *DefaultResolution: 600dpi *Resolution 150dpi ... *Resolution 300dpi ... *Resolution 600dpi ...
and
*DefaultColors: Color *Colors Gray ... *Colors Color ... ... *DefaultInkCartridge: Color *InkCartridge Black ... *InkCartridge Color ... ... *DefaultResolution: 300dpi *Resolution 150dpi ... *Resolution 300dpi ... *Resolution 600dpi ...
In certain circumstances it makes sense to have several queues with their respective settings for the same printer due to the following reasons:
It might be necessary to change several options when switching between print modes, especially in the case of color ink jet printers, as in the following examples:
- For "mono"
Colors=GrayandInkCartridge=Black - For "color"
Colors=ColorandInkCartridge=Color
Some particular print modes might only work with certain resolutions, especially in the case of color ink jet printers as in the following examples:
- The resolutions
150dpi,300dpi, and600dpiwork for "mono". - Only the resolutions
150dpiand300dpiwork for "color".
Since SuSE Linux 8.2 (exactly since Foomatic version 3.x) there is the "Printout Mode" option in most of the Foomatic PPD files for inkjet printers. When the user selects a printout mode then all the individual option settigs which are necessary for the particular printing mode are set simulaneously. Therefore one PPD file for one printer is sufficient in this case.
The machines "earth" and "moon" are CUPS clients without queues. In addition to "root", the normal users "tux" and "geeko" are on these machines, too.
Unless the queues have been configured otherwise, the queue "mono" always produces grayscale printouts with a 600 dpi resolution for all machines and the queue "color" always produces color printouts with a 300 dpi resolution.
Now the options will be changed in the following order:
"root" executes the following command on "sun":lpadmin -p mono -o Resolution=150dpi
to change the default resolution value to 150 dpi in the PPD file /etc/cups/ppd/mono.ppd
*DefaultColors: Gray *Colors Gray ... *Colors Color ... ... *DefaultInkCartridge: Black *InkCartridge Black *InkCartridge Color ... *DefaultResolution: 150dpi *Resolution 150dpi ... *Resolution 300dpi ... *Resolution 600dpi ...
Thus, the queue "mono" prints in grayscale with a 150 dpi resolution for all users on all machines.
Then "root" executes the following command on "sun":lpoptions -p mono -o Resolution=300dpi
to set the default resolution value to 300 dpi only for the machine "sun" in its file /etc/cups/lpoptions:
Dest mono Resolution=300dpi
Thus, "mono" prints in grayscale with a 300 dpi resolution for all the users on "sun" and in grayscale with a 150 dpi resolution for all users on "earth" and "moon".
Now "root" executes the following command on "earth":lpoptions -p mono -o Resolution=600dpi
to set the default resolution value to 600 dpi only for the machine "earth" in its file /etc/cups/lpoptions:
Dest mono Resolution=600dpi
Thus, "mono" prints in grayscale with a 600 dpi resolution for all the users on "earth", in grayscale with a 300 dpi resolution for all the users on "sun", and in grayscale with a 150 dpi resolution for all the users on "moon".
The normal user "tux" executes the following command on "earth":lpoptions -p mono -o Resolution=300dpi
to set his default resolution value as 300dpi in his home directory in the file ~/.lpoptions:
Dest mono Resolution=300dpi
Thus, "mono" prints in grayscale with a 300 dpi resolution for the user "tux" on "earth" and in grayscale with a 600 dpi resolution for the rest of users on "earth". The settings on "sun" and "moon" remain unchanged.
The user "geeko" executes on "earth" the commandlpoptions -p mono -o Colors=Color
to change his settings for the queue "mono". The new settings for the user "geeko" will be saved in the file ~/.lpoptions in his home directory:
Dest mono Colors=Color
Geeko's settings for the queue "mono" on "earth" make no sense, because two contradictory values are used: Colors=Color and InkCartridge=Black.
"geeko" executes the following command on "earth":lpoptions -p color -o Resolution=600dpi
to set his options for the queue "color" as follows. The new settings will be saved in his file ~/.lpoptions:
Dest color Resolution=600dpi Dest mono Colors=Color
The settings of the queue "color" for "geeko" on "earth" are wrong, because the only deployed value is Resolution=600dpi, which does not work for this printer (see above). This results in the queue "color" no longer working for "geeko" on "earth".
"geeko" executes the following command on "earth":lpoptions -p color -o Resolution=1200dpi -o Foo=Bar
to set his options for the queue "color" as follows. The new settings will be saved in his file ~/.lpoptions:
Dest color Resolution=1200dpi Foo=Bar Dest mono Colors=Color
It is possible to set values like Resolution=1200dpi and options like Foo=Bar, even though they are not considered in the PPD file. When printing, however, the default value from the PPD file (Resolution=300dpi) will be used and the option (Foo=Bar) will be ignored. Thus, the queue "color" works again for "geeko" on "earth", but the set values are totally unsuitable.
When "root" deletes the queue "mono" on "sun" with the commandlpadmin -x mono
the now invalid entries in the files lpoptions mentioned above are not deleted, but remain unchanged.
"root" creates again the queue "mono" on "sun", but a different PPD file is used:
*DefaultColours: Gray *Colours Gray ... *Colours Color ... ... *DefaultResolution: 300x300dpi *Resolution 300x300dpi ... *Resolution 600x600dpi ...
None of the previous entries in the files lpoptions are valid for the new queue "mono", since either the option names no longer match (Colours instead of Colors) so the option is ignored or the option values no longer match (300x300dpi and 600x600dpi instead of 150dpi, 300dpi, and 600dpi) so the default value from the PPD file is used.
General Rules for Setting Definitions:
- When the user customizes an option (e.g., in his file
~/.lpoptions), those settings will be used for the print job. - If a file
/etc/cups/lpoptionsis already available on the computer, only the options not previously defined by the user will be used for the print job. - If any invalid option has been defined in the previous steps, it will be ignored. If any option value is invalid, it will be replaced with the default value from the PPD file.
- Default values for the corresponding queue (specially default values from the PPD file) will be used for the remaining options.
The commandlpoptions -p "queue" -l
displays the possible settings. The values that, according to the rules above, will be used for a print job are marked with a preceding *.
According to this, the user "geeko" on "earth" might have used the following command in item 7lpoptions -p color -l
to verify which settings would be used for his print job via the queue "color". He would have seen that these do not correspond to the settings in his file ~/.lpoptions, because the output would be
Colors: Gray *Color InkCartridge: Black *Color Resolution: 150dpi *300dpi 600dpi
Suggestion for Keeping an Overview:
Never define general presettings separately on each machine. Set the default values in the PPD file:
- If possible, do not use any
/etc/cups/lpoptionsfiles. - If possible, do not execute the command
lpoptionsas "root" on each machine. Instead, execute the commandlpadminon the CUPS server.
Remove any unsuitable or unwanted setting from the PPD file manually or add appropriate constraints to the PPD file:
For example, to avoid unsuitable settings as described in the items 5 and 6 above, "root" can edit the PPD files /etc/cups/ppd/mono.ppd and /etc/cups/ppd/color.ppd manually on the CUPS server as follows (see also the article "ASCII Editors"):
*DefaultColors: Gray *Colors Gray ... ... *DefaultInkCartridge: Black *InkCartridge Black ... ... *DefaultResolution: 600dpi *Resolution 150dpi ... *Resolution 300dpi ... *Resolution 600dpi ...
and
*DefaultColors: Color *Colors Color ... ... *DefaultInkCartridge: Color *InkCartridge Color ... ... *DefaultResolution: 300dpi *Resolution 150dpi ... *Resolution 300dpi ...
Adding appropriate constraints to the PPD file is another solution. The constraints avoid that the user can select incompatible value combinations in the PPD file, but often appropriate constraints are missing in the PPD files. The example PPD file with constraints may look as follows. Note that each constraint must be specified in both ways - for example: When "*Colors Gray" was selected then "*InkCartridge Color" is no longer allowed and when "*InkCartridge Color" was selected then "*Colors Gray" is no longer allowed.
*UIConstraints: *Colors Gray *InkCartridge Color *UIConstraints: *InkCartridge Color *Colors Gray *UIConstraints: *Colors Color *InkCartridge Black *UIConstraints: *InkCartridge Black *Colors Color *UIConstraints: *Colors Color *Resolution 600dpi *UIConstraints: *Resolution 600dpi *Colors Color *UIConstraints: *InkCartridge Color *Resolution 600dpi *UIConstraints: *Resolution 600dpi *InkCartridge Color ... *DefaultColors: Color *Colors Gray ... *Colors Color ... ... *DefaultInkCartridge: Color *InkCartridge Black ... *InkCartridge Color ... ... *DefaultResolution: 300dpi *Resolution 150dpi ... *Resolution 300dpi ... *Resolution 600dpi ...
Some values might be possible for the printer, but unwanted for a particular queue, such as high resolutions for a "draft" queue. Such option settings should be removed for the particular queue. After manually changing PPD files, the CUPS daemon must be forced to reread the files by using the command rccups reload or rccups restart.
The users must be informed about any queue modification on the CUPS server, if the modification leads to the invalidity of the settings in the users' ~/.lpoptions files, especially if a queue is deleted completely or if a different PPD file will be used for an existing queue.
Then, the users can use the commandlpoptions -x "queue"
or, in the example above,lpoptions -x mono
to remove the corresponding entries from their ~/.lpoptions files then reconfigure their personal settings for the relevant queue.
lpoptions -x does not work for deleted queues. Invalid entries can be either ignored or manually deleted from the ~/.lpoptions file (see the SDB article "ASCII Editors").
If personal settings will be newly configured, the whole file should first be deleted with the commandrm ~/.lpoptions
SDB:Printer Configuration from SuSE Linux 8.1 on
SDB:Print Settings for ASCII Texts with CUPS
Keywords: print | printer | cups | settings | options

