Print filter definition

When adding a new filter, you must define the characteristics of its use.

To defining the characteristics of a filter's use, issue the lpfilter command with arguments that specify the values of the following filter characteristics:

  • Name of the filter (that is, a command name)
  • Types of input it will accept
  • Types of output it will produce
  • Types of printers to which it will send jobs
  • Names of specific printers to which it will send jobs
  • Type of the filter (whether it is a fast filter or a slow filter)
  • Options

See Adding a filter to the print service for more information.

Filter definitions, which can be stored in a file or entered directly on the command line, have the following format:

   Command: command-pathname [options]
   Input types: input-type-list
   Output types: output-type-list
   Printer types: printer-type-list
   Printers: printer-list
   Filter type: fast or slow
   Options: template-list

The information can appear in any order. Not all of the information must be provided. When you do not specify values for the items listed below, default values are assigned.

lpfilter Arguments Default
Command: (no default)
Input types: any
Output types: any
Printer types: any
Printers: any
Filter type: slow
Options: (no default)

Default values define a flexible filter, so at minimum you must supply the input and output type(s). When you enter a list, you can separate the items in it with blanks or commas, unless it is a template-list. Items in a template-list must be separated by commas.

Each of these characteristics is described as follows:

  • Command: The full path of the filter program.

    If there are any fixed options that the program always needs, include them here.

  • Input types: The list of file content types that the filter can process.

    The print service does not impose a limit on the number of input types that can be accepted by a filter, but most filters can take only one. Several file types may be similar enough so that the filter can handle them. You can use any name having a maximum of 14 alphanumeric characters and dashes (not underscores). Because the print service uses these names to match a filter with a file type, follow a consistent naming convention. For example, if more than one filter can accept the same input type, use the same name for that input type when you specify it for each filter. Advise your users of the names so they know how to identify the type of a file when submitting that file for printing.

  • Output types: The list of file types that the filter can produce as output.

    For each input type, the filter produces a single output type. The output type may vary, however, from job to job. The names of the output types are restricted to 14 alphanumeric characters and dashes.

    These names should either match the types of printers you have on your system or match the input types handled by other filters. The print service groups filters together in a shell pipeline if it finds that several passes by different filters are needed to convert a file. Try to find a set of filters that take (as input types) all the different files your users may want printed and converts those files directly into types your printers can handle.

  • Printer types: A list of printer types into which the filter can convert files.

    For most filters, this list is identical to the list of output types.

    For example, you may have a printer that is given a single type for purposes of initialization (see Printer types), but which can recognize several different types of files. In essence, this printer has an internal filter that converts the various types into one that it can handle. Thus, a filter may produce one of several output types that match the file types that the printer can handle. Label the filter as working with that printer type.

    As another example, you may have two different models of printers that are listed as accepting the same types of files. However, due to slight differences in manufacture, one printer deviates in the results it produces. You label the printers as being of different printer types, say A and B, where B is the one that deviates. You create a filter that adjusts files to account for the deviation produced by printers of type B. Because this filter is needed only for those printer types, you list it as working only on type B printers.

    For most printers and filters, you can leave this part of the filter definition blank.

  • Printers: You may have some printers that, although they are of the correct type for a filter, are in other ways not adequate for the output that the filter produces.

    For example, you may want to dedicate one printer for fast turnaround. Only files that the printer can handle without filtering will be sent to that printer. Other printers, of identical type, you allow to be used for files that may need extensive filtering before they can be printed. In this case, label the filter as working with only the latter group of printers.

    In most cases, a filter works with all printers that accept its output, so you can usually skip this part of the filter definition.

  • Filter type: The print service recognizes fast filters and slow filters.

    Fast filters are labeled fast because they incur little overhead in preparing a file for printing and because they must have access to the printer when they run. A filter that is to detect printer faults must be a fast filter. A filter that uses the PRINTER keyword as a filter option must be installed as a fast filter.

    Slow filters are filters that incur a lot of overhead in preparing a file and do not require access to a printer. The print service runs slow filters in the background, without tying up a printer. This allows files that do not need slow filtering to move ahead. Printers will not be left idle while a slow filter works on a file if other files can be printed simultaneously.

    Slow filters that are invoked by modes (using the -y option), must be run on the computer where the print request was issued. The print service cannot pass values for modes to server machines. It can, however, match a file content type (specified after the -T option of the lp command) to a content type on a server machine. Therefore, to activate special modes on a server machine, you must specify content types that will allow the print service to match input types and output types.

  • Options: Options specify how different types of information is transformed into command line arguments to the filter command.

    This information may include specifications from a user (with the print request), the printer definition, and the specifications implemented by any filters used to process the request.

    There are 13 sources of information, each of which is represented by a keyword. Each option is defined in a template, which is a statement in the following format:

    keyword pattern=replacement

    This type of statement is interpreted by the print service to mean: "When the information referred to by keyword has the value matched by pattern, take the replacement string, replace any asterisks it contains with the pattern specified or expand any regular expressions it contains, and append the result to the command line."

    The options specified in a filter definition may include none, all, or any subset of these 13 keywords. In addition, a single keyword may be defined more than once, if multiple definitions are required for a complete filter definition. See Option definition with templates.

When you have gathered enough information to define the characteristics of your filter, you are ready to run the lpfilter command, using your data as arguments. Because there are so many arguments and because some of them may need to be entered more than once (with different values), record this information first in a separate file and edit it, if necessary. You can then use the file as input to the lpfilter command and avoid entering each piece of information separately.