Sun Microsystems, Inc.
spacerspacer
spacer www.sun.com docs.sun.com |
spacer
black dot
 
 
7.  Customizing the LP Print Service (Tasks) Creating a New Print Filter Writing a Print Filter Program Requirements for a Print Filter Program  Previous   Contents   Next 
   
 

Creating a Print Filter Definition

A print filter definition tells the LP print service about the filter, what print filter program to run, what kind of conversion it does, and so on. A set of filter descriptor files are provided in the /etc/lp/fd directory. These files describe the characteristics of the filters (for example, fast or slow filter), and point to the filter programs (for example, /usr/lib/lp/postscript/postdaisy).

When defining a new print filter, in addition to writing a filter program, you must create a print filter definition. A print filter definition contains the following information used by the LP print service:

  • Name of the filter program to run

  • Input types it accepts

  • Output types it produces

  • Printer types to which it can send jobs

  • Names of specific printers to which it can send jobs

  • Filter types (either fast or slow)

  • Options

You can type the characteristics as direct input to the lpfilter command. You also can create a file that specifies the filter's characteristics, and use the file name as input to the lpfilter command. Such a file is called a filter descriptor file and should be located in the /etc/lp/fd directory. These files are not the filters themselves, but rather point to the filters.

Whether you store the information in a file, or enter it directly on the command line, use 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

Note - If you provide more than one definition (that is, more than one line) for any filter characteristic other than Options, only the second definition will be used by the print service.


The information can be arranged in any order, and not all the information is required. When you do not specify values, those shown in the following table are assigned by default. They are not very useful, which is why you should specify explicit values.

Table 7-5 Default Values for lpfilter Arguments

Item

Default

Input types

any

Output type

any

Printer types

any

Printers

any

Filter type

slow

Command

Use the full path of the filter program. If there are any fixed options that the program always needs, include them here.

Input Types

Input types is a list of file content types that the print filter can process. The LP print service does limit the number of input types, but most filters can accept only one type. Several file types can be similar enough that the filter can deal with them. You can use whatever names you like, with a maximum of 14 alphanumeric characters and dashes. Do not use underscores as part of the input type name.

The LP print service uses these names to match a filter to a file type, so 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. Inform your users of these names so they know how to identify the file type when submitting a file for printing.

Output Types

Output types is 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 can vary, however, from job to job. The name of the output type is restricted to 14 alphanumeric characters and dashes.

The output type names should either match the types of available (local or remote) printers, or match the input types handled by other filters. The LP print service groups filters in a shell pipeline if it finds that several passes by different filters are needed to convert a file. It is unlikely that you will need this level of sophistication, but the LP print service allows it. Try to find a set of filters that takes as input types all the different files the users might want printed, and that converts those files directly into file types the printer can handle.

Printer Types

Printer types is a list of the types of printers into which the print filter can convert files. For most printers and filters, you can leave this part of the filter definition blank, because it is identical to the list of output types. But it can be different. For example, you could have a printer with a single printer type for purposes of initialization, but which can recognize several different file content types. Essentially, this printer has an internal filter that converts the various file types into one that it can handle. Thus, a filter might produce one of several output types that match the file types that the printer can handle. The print filter should be marked as working with that printer type.

As another example, you might have two different models of printers that are listed as accepting the same file types. Due to slight differences in manufacture, however, 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 would list it as working only on type B printers.

Printers

A print filter is normally able to work with all printers that accept its output, so you can usually skip this part of the filter definition.

You might, however, have some printers that are or inappropriate for the output that the filter produces. For example, you might want to dedicate one printer for fast turnaround, only sending files that require no filtering to that printer. Other printers of identical type can be used for files that need extensive filtering before they can be printed.

Filter Type

The LP print service recognizes fast and slow filters, as described in "Types of Filters".

Slow filters that are invoked by printing modes (using the lp -y command) must be run on the system from which the print request originated. The LP print service cannot pass values for modes to print servers. It can, however, match a file content type (specified after the -T option of the lp command) to a content type on a print server. Therefore, if you want to activate special modes on a print server, you must specify content types that permit the LP print service to match input types and output types.

Options

Options specify how different types of information are converted into command-line arguments to the filter command. This information can include specifications from a user (with the print request), the printer definition, and the specifications implemented by any filters used to process the request.

Defining Print Filter Options With Templates

There are 13 sources of information for defining print filter options, each of which is represented by a keyword. Each option is defined in a template. A template is a statement in a filter definition that defines an option to be passed to the filter command, based on the value of one of the characteristics of the filter.

The options specified in a filter definition can include none, all, or any subset of the 13 keywords. In addition, a single keyword can be defined more than once, if multiple definitions are required for a complete filter definition. The following table contains descriptions of the 13 keywords available for defining Options in a print filter definition.

Table 7-6 Print Filter Options Keywords

Characteristic

Keyword

Possible Patterns

Example

Content type (input)

INPUT

content-type

troff

Content type (output)

OUTPUT

content-type

postscript, impress

Printer type

TERM

printer-type

att495

Printer name

PRINTER

printer-name

lp1

Character pitch

CPI

scaled-decimal

10

Line pitch

LPI

scaled-decimal

6

Page length

LENGTH

scaled-decimal

66

Page width

WIDTH

scaled-decimal

80

Pages to print

PAGES

page-list

1-5,13-20

Character set

CHARSET

character-set

finnish

Form name

FORM

form-name

invoice2

Number of copies

COPIES

integer

3

Special modes

MODES

mode

landscape

A print filter definition can include more than one template. Multiple templates are entered on a single line and separated with commas, or they are entered on separate lines, preceded by the Options: prefix.

The format of a template is as follows:

keywordpattern = replacement

The keyword identifies the type of option being registered for a particular characteristic of the filter.

The pattern is a specific option for the keyword.

The replacement is what happens when the keyword has the noted value.

For an example of how an option is defined for a particular filter, suppose you want to have the print service scheduler assign print requests to filters following this criteria:

  • If the type of OUTPUT to be produced by the filter is impress, then pass the -I option to the filter.

  • If the type of OUTPUT to be produced by the filter is postscript, then pass the -P option to the filter.

To specify these criteria, provide the following templates as options to the lpfilter command:

Options: OUTPUT impress=-I, OUTPUT postscript=-P

If the Options line becomes too long, put each template on a separate line, as follows:

Options: OUTPUT impress=-I
Options: OUTPUT postscript=-P 
 
 
 
  Previous   Contents   Next