A print filter can be simple or complex, but it has to meet the following requirements:
The filter should get the contents of a file from its standard input and send the converted file to the standard output.
A program cannot be used as a filter if it references external files. You might be tempted to use a program such astroff, nroff, or a similar word processing program as a filter. The LP print service does not recognize references to other files, known as include files, from a filter program. Because troff and nroff programs allow include files, they can fail when used as filters. If the program needs other files to complete its processing. The program t should not be used as a filter.
The filter should not depend on files that normally would not be accessible to a user. If a filter fails when run directly by a user, it will fail when run by the LP print service.
A slow filter can send messages about errors in the file to standard error. a fast filter should not. Error messages from a slow filter are collected and sent to the user who submitted the print request.
If a slow filter dies because it received a signal, the print request is stopped and the user who submitted the request is notified. Likewise, if a slow filter exits with a nonzero exit code, the print request is stopped and the user is notified. The exit codes from fast filters are treated differently.
If you want the filter to detect printer faults, it should also meet the following requirements:
If possible, the filter should wait for a fault to be cleared before exiting. The filter should also continue to print at the top of the page where printing stopped after the fault is cleared. If you do not want use the continuation feature, the LP print service stops the filter before alerting the administrator.
The filter should send printer fault messages to its standard error as soon as the fault is recognized. The filter does not have to exit, but can wait for the fault to be cleared.
The filter should not send messages about errors in the file to standard error. These messages should be included in the standard output, where they can be read by the user.
The filter should exit with a zero exit code if the file is finished printing (even if errors in the file have prevented it from being printed correctly).
The filter should exit with a nonzero exit code, only if a printer fault has prevented the filter from finishing a print request.
When added to the filter table, the filter must be added as a fast filter.