Creating and using printer filters
A ``printer filter'':
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:
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:Table 4-8, ``Printer filter definition fields'', describes each of these fields.
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.
To use the new printman filter to print the
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 = land2To 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:
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:
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 = -dTo 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:
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.
Table 4-8 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.