DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Managing printers and print jobs

Creating and using printer filters

A ``printer filter'':

The print service supports forms and filters. However, there are very few cases where you need to use these features.

You can use filters to change the output to the printer. For example, you can create a filter that allows users to print a manual page by piping the output of man(C) to lp(C) without printing the control characters.

To create a filter:

  1. Create a printer filter definition file.

    For example, create a file /tmp/printmandef and include this information (substitute your information for the values in bold):

       Input types: nroff,man
       Output types: simple
       Printer types: any
       Printers: any
       Filter type: slow
       Command: col -b
       Options:
    
    ``Printer filter definition fields'', describes each of these fields.

  2. Change the permissions on the filter definition file:

    chmod +x printmandef

  3. In the Printer Manager, select Filters from the System menu.

  4. Click on New.

    Enter the name of the new filter in the ``Filter Name'' field and the name of the filter definition file in the ``Filename'' field.

    In our example, the filename is /tmp/printmandef, and the filter name is the name that you want the print service to assign to the form, for example, printman.

    Clicking on OK in the New Filter window adds the filter definition (printman) in the /usr/spool/lp/admins/lp/filter.table file.

The filter is now ready to use.

To use the new printman filter to print the lpfilter(ADM) manual page without the control characters, enter:

man lpfilter | lp -d printer_name -Tman

Here is a sample filter definition that formats an ASCII document in PostScript so that a PostScript printer can read it:

   Input types:
   Output types: ps,postscript
   Printer types: laser
   Printers: hplaser
   Filter type: fast
   Command: /usr/spool/lp/bin/text2post
   Options: MODES portrait = port, MODES landscape = land, MODES landscape2 = land2
To add the printps filter, proceed from step 3. To use the printps filter to print a file in landscape mode with lp(C) on the printer apple, enter:

lp -d apple -Tps -y land file

Here is a filter definition that allows the user to define which pages to print:

   Input types: simple
   Output types: simple
   Filter type: fast
   Command: /usr/spool/lp/bin/pages
   Options: PAGES * = *
To add the printpage filter, proceed from step 3. To use the printpage filter to print specific pages, enter:

lp -d laser -P 3-5,9 file

In this case, lp prints only pages 3 through 5 and page 9 of file on the printer laser.

Here is a filter definition that translates a PostScript file to epson format for printing on a dot matrix printer:

   Input types: postscript ps
   Output types: epson
   Filter type: slow
   Commands: /usr/spool/lp/bin/ps2epson
   Options: MODES draft = -d, MODES low = -d
To add the printepson filter, proceed with step 3 of the procedure above. To use the printepson filter to print a PostScript file on the Epson dot matrix printer, enter:

lp -d dotepson -Tps file

To examine an existing filter, select Filters from the System menu. Then, select the filter to examine and click on Examine.

To modify an existing filter, select Filters from the System menu. Then, select the filter to modify and click on Modify. Enter the name of the modified filter definition file in the ``Filename'' field. This associates the new filter definition file with the filter name.

To remove the filter from the system, select Filters from the System menu. Then, select the filter to delete and click on Delete.

Printer filter definition fields

Field Description
Input types List of file types that the filter can process.
Output types List of file types that the filter can produce as output. This should match the content type of at least one printer.
Printer types List of printer types into which the filter can convert files. For most printers and filters, you can use the default (``any'') or leave this field blank.
Printers List of printers that can use this filter. For most filters, you can use the default (``any'') or leave this field blank.
Filter type Type of filter (either fast or slow). A fast filter is one that incurs little overhead in preparing a file or one that must have direct access to the printer. A slow filter is the opposite. The print service runs slow filters in the background, allowing files that need fast filtering (or no filtering) to be printed first.
Command Full pathname of the command that defines the filter program. Include any fixed options that the filter always requires.
Options Options to lp(C). These lp options are converted into options for the filter.

See also:

About content types

The ``content type'' tells the print service what types of files can be printed on a particular printer type (or interface script). Most printers can print only one type of file. For them, the content type is likely to be identical to the printer type. Some printers, however, can accept several different types of file and print their contents properly. When adding this kind of printer, specify the names of the content types the printer accepts.

When a user submits a file for printing, the print service searches for a printer capable of handling the job. The print service can identify an appropriate printer through either the content type name or the printer type name.

To specify the content types that a printer can accept:

  1. In the Printer Manager, select the printer from the list.

  2. Select Advanced from the Settings menu, then select Content Types.

If several different types of printer accept the same content type, use the same content type names when you add those printers. This makes it easier for users because they can use the same name to identify the type of file they want to print, regardless of the printing destination.

For example, several manufacturers produce printers that accept PostScript files. Although these printers might require different interface scripts so each can be properly initialized, they all might be capable of printing the same content type, which you might call PostScript. As another example, several manufacturers produce printers that accept ANSI X3.64-defined escape sequences. However, the printers might not support all the ANSI capabilities, or each might support different sets of capabilities. You can specify different content type names for these printers to differentiate them.

The print service recognizes special meanings for these content types:


simple
The most common type of file on the UNIX system is known as simple. The print service assumes this file type contains only printable ASCII characters and the backspace, tab, line feed, form feed, and carriage return control characters. See the lpadmin(ADM) manual page for more information.

terminfo
The terminfo content type name does not refer to a particular type of file, but instead refers to all the types represented in the terminfo database. It is not likely that any printer is capable of handling all the types listed in the database, but this name is reserved for describing possible filter capabilities.

any
The print service reserves the content type name any for describing the types of files a filter can accept or produce. This name should not be used as a content type when adding a printer.

If a printer can handle simple file types, include simple in the list of ``Supported'' content types. If you do not want a printer to accept simple file types, you must include an alternate list of content types that the printer accepts. (If no other content type is appropriate, use the printer interface script.)

If you do not define the types of files a printer can accept, the print service assumes the printer can print only files of content type simple. This may be sufficient if users choose the proper printer and make sure the files are properly prepared for the printer before they are submitted for printing.

Detecting printer fault indicators with filters

Just as converting a file and handling special printing modes is printer-specific, so is printer fault detection. The print service attempts to do this in general, and for most printers, it properly detects faults. However, it is limited to checking for ``hangups'' and excessive delays in printing. The print service cannot determine the cause of the fault, so it cannot tell you exactly what to look for.

A properly designed filter can provide better fault coverage. Some printers can send a message to the host describing the reason for a fault. Others indicate a fault by dropping the carrier or shutting off data flow. A filter can serve you by giving more information about a fault and detecting more of them.

Filters can wait for a printer fault to clear and then resume printing. This allows for more efficient printing when a fault occurs because the print job that was interrupted does not have to be reprinted in its entirety. Only a filter that understands the control sequences used by a printer knows where a file breaks into pages. Thus, only the filter knows how far back to go in the file to restart properly.

The print service has a simple interface that lets the filter get the fault information to you and restart the print job if it can. The alerting mechanism is handled by the print service. The interface program that manages the filter takes all error messages from the filter and places them into an alert message that can be sent to you. Thus, you see any fault descriptions that the filter puts out. If you set the printer configuration so that printing should automatically resume after a fault is cleared, the interface program keeps the filter active so that it can pick right up where it left off.

See also:


Next topic: Font cartridges, character sets, print wheels
Previous topic: Mounting and unmounting forms

© 2007 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 05 June 2007