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 Creating a Print Filter Definition Options  Previous   Contents   Next 
   
 

In both templates, the keyword is defined as OUTPUT. In the first template, the pattern is impress and the value of the replacement is --I. In the second template, the value of pattern is postscript and the value of replacement is -P.

To find out which values to supply for each type of template (that is, for the pattern and replacement arguments for each keyword), consider the following:

  • The values for the INPUT templates come from the file content type that needs to be converted by the filter.

  • The values for the OUTPUT templates come from the output type that has to be produced by the filter.

  • The value for the TERM template is the printer type.

  • The value for the PRINTER template is the name of the printer that will print the final output.

  • The values for the CPI, LPI, LENGTH, and WIDTH templates come from the user's print request, the form being used, or the default values for the printer.

  • The value for the PAGES template is a list of pages that should be printed. Typically, it is a list of page ranges separated by commas. Each page range consists of a pair of numbers separated by a dash, or a single number. (For example, 1-5,6,8,10 indicates pages 1 through 5, plus pages 6, 8, and 10.) However, whatever value was given in the -P option to a print request is passed unchanged.

  • The value for the CHARSET template is the name of the character set to be used.

  • The value for the FORM template is the name of the form requested by the lp -f command (the command used to submit a print request).

  • The value of the COPIES template is the number of copies of the file to print. If the filter uses this template, the LP print service will reduce to one the number of copies of the filtered file it prints, since this "single copy" includes the multiple copies produced by the filter.

  • The value of the MODES template comes from the lp -y command. Because a user can specify several -y options, there might be several values for the MODES template. The values will be applied in the left-to-right order given by the user.

The replacement part of a template shows how the value of a template should be given to the filter program. It is typically a literal option, sometimes with the placeholder asterisk (*) included to show where the value goes. The pattern and replacement also can use the regular expression syntax of the ed command for more complex conversion of user input options into filter options. All regular expression syntax of ed is supported, including the \( ... \) and \n constructions, which can be used to extract portions of the pattern for copying into the replacement, and the &, which can be used to copy the entire pattern into the replacement. For more information, see ed(1).


Note - If a comma or an equal sign (=) is included in a pattern or a replacement, precede it with a backslash (\). A backslash in front of any of these characters is removed when the pattern or replacement is used.


How to Create a New Print Filter

  1. Log in as superuser, lp, or assume an equivalent role on the print server.

  2. Create a print filter program.

    For information on print filter programs, see "Writing a Print Filter Program". By convention, filter programs for PostScript printers are located in the /usr/lib/lp/postscript directory. You should put programs you create under the /usr/lib/lp directory in a directory of your choosing.

  3. Create a print filter definition.

    For information on print filter definitions, see "Creating a Print Filter Definition". You should save the printer filter definition in a text file. By convention, filter definitions are located in the /etc/lp/fd directory and are identified with the .fd suffix.

  4. Add the print filter to a print server.

    For instructions, see "How to Add a Print Filter".

Examples--Creating a New Print Filter

The following example shows a print filter definition to convert N37 or Nlp to simple.

Input types: N37, Nlp, simple
Output types: simple
Command: /usr/bin/col
Options: MODES expand = -x
Options: INPUT simple = -p -f

In this example, the print filter program is named col. Once you add the new print filter to a print server, a user's print requests will be handled as follows:

  • When a user enters the following command:

    $ lp -y expand report.doc

    The print filter program is run with the following arguments to convert the file:

    /usr/bin/col -x -p -f
  • When a user enters the following command:

    $ lp -T N37 -y expand report.doc

    The print filter program is run with the following arguments to convert the file:

    /usr/bin/col -x

The following example shows a print filter definition to convert from troff to PostScript.

Input types: troff
 
Output types: postscript
 
Printer types: PS
 
Filter type: slow
 
Command: /usr/lib/lp/postscript/dpost
 
Options: LENGTH * = -l*
 
Options: MODES port = -pp, MODES land = -pl
Options: MODES group \=\([1-9]\) = -n\l

In this example, the filter program is named dpost. It takes one input type, troff, produces a postscript output, and works with any printer of type PS (PostScript). Users need to give just the abbreviation port or land when they ask for the paper orientation to be in portrait mode or landscape mode. Because these options are not intrinsic to the LP print service, users must specify them using the lp -y command.

After you add the new print filter to a print server, print requests will be handled as follows:

  • When a user enters the following command to submit a troff file type for printing on a PostScript printer (type PS), with requests for landscape orientation and a page length of 60 lines:

    $ lp -T troff -o length=60 -y land -d luna ch1.doc

    The print filter program dpost is run with the following arguments to convert the file:

    /usr/lib/lp/postscript/dpost -l60 -pl luna ch1.doc
  • When a user enters the following command:

    $ lp -T troff -y group=4 -d luna ch1.doc

    The print filter program dpost is run with the following arguments to convert the file:

    /usr/lib/lp/postscript/dpost -n4
 
 
 
  Previous   Contents   Next