filter(7)
๐ filter(7) ๐
okay bestie, sit down, hydrate, because this is the filter(7) page from OpenPrinting and it's genuinely the blueprint for how CUPS does file conversion ๐
โจ NAME โจ
filter โ cups file conversion filter interface
๐ฆ SYNOPSIS ๐ฆ
filter job user title num-copies options [ filename ]
#include <cups/cups.h>
ssize_t cupsBackChannelRead(char *buffer, size_t bytes,
double timeout);
cups_sc_status_t cupsSideChannelDoRequest(cups_sc_command_t command,
char *data, int *datalen,
double timeout);
#include <cups/ppd.h>
const char *cupsGetOption(const char *name, int num_options,
cups_option_t *options);
int cupsMarkOptions(ppd_file_t *ppd, int num_options,
cups_option_t *options);
int cupsParseOptions(const char *arg, int num_options,
cups_option_t **options);
ppd_choice_t *ppdFindMarkedChoice(ppd_file_t *ppd, const char *keyword);
void ppdMarkDefaults(ppd_file_t *ppd);
ppd_file_t *ppdOpenFile(const char *filename);
๐ DESCRIPTION ๐
So the CUPS filter interface is basically the standard method for adding support for new document types or printers to CUPS. Every filter converts from one or more input formats into another format that can either be printed directly or piped into another filter until it reaches something printable. it's giving relay race ๐โโ๏ธ
Filters MUST be capable of reading from a filename on the command-line or from the standard input, copying the standard input to a temporary file as required by the file format. All output MUST be sent to the standard output. Filters MUST NOT attempt to communicate directly with the printer, other processes, or other services. ๐ซ (yes this is a hard boundary, no sneaky side chats)
The command name (argv[0]) is set to the name of the destination printer but is also available in the PRINTER environment variable.
๐ OPTIONS ๐
Options are passed in argv[5] and are encoded from the corresponding IPP attributes used when the job was submitted. Use the cupsParseOptions() function to load the options into a cups_option_t array and the cupsGetOption() function to get the value of a specific attribute. Be careful to look for common aliases of IPP attributes such as "landscape" for the IPP "orientation-requested" attribute. ๐ (yes the names do NOT always match, keep up)
Options passed on the command-line typically do not include the default choices the printer's PPD file. Use the ppdMarkDefaults() and cupsMarkOptions() functions in the CUPS library to apply the options to the PPD defaults and map any IPP attributes to the corresponding PPD options. Use ppdFindMarkedChoice() to get the user-selected choice for a PPD option. For example, a filter might use the following code to determine the current value of the Duplex PPD option:
ppd_file_t *ppd = ppdOpenFile(getenv("PPD"));
cups_option_t *options = NULL;
int num_options = cupsParseOptions(argv[5], 0, &options);
ppdMarkDefaults(ppd);
cupsMarkOptions(ppd, num_options, options);
ppd_choice_t *choice = ppdFindMarkedChoice(ppd, "Duplex");
Raster filters should use option choices set through the raster page header, as those reflect the options in effect for a given page. Options specified on the command-line determine the default values for the entire job, which can be overridden on a per-page basis. ๐
๐ข LOG MESSAGES ๐ข
Messages sent to the standard error are generally stored in the printer's "printer-state-message" attribute and the current ErrorLog file. Each line begins with a standard prefix:
ALERT: messageโ Sets the"printer-state-message"attribute and adds the specified message to the currentErrorLogusing the"alert"log level.ATTR: attribute=value [ ... attribute=value]โ Sets the named job or printer attribute(s). The following job attributes can be set:"job-media-progress". The following printer attributes can be set:"auth-info-required","marker-colors","marker-high-levels","marker-levels","marker-low-levels","marker-message","marker-names","marker-types","printer-alert", and"printer-alert-description".CRIT: messageโ Sets the"printer-state-message"attribute and adds the specified message to the currentErrorLogusing the"critical"log level.DEBUG: messageโ Adds the specified message to the currentErrorLogusing the"debug"log level.DEBUGmessages are never stored in the"printer-state-message"attribute.DEBUG2: messageโ Adds the specified message to the currentErrorLogusing the"debug2"log level.DEBUG2messages are never stored in the"printer-state-message"attribute.EMERG: messageโ Sets the"printer-state-message"attribute and adds the specified message to the currentErrorLogusing the"emergency"log level.ERROR: messageโ Sets the"printer-state-message"attribute and adds the specified message to the currentErrorLogusing the"error"log level.INFO: messageโ Sets the"printer-state-message"attribute. If the currentLogLevelis set to"debug2", also adds the specified message to the currentErrorLogusing the"info"log level.NOTICE: messageโ Sets the"printer-state-message"attribute and adds the specified message to the currentErrorLogusing the"notice"log level.PAGE: page-number #-copiesPAGE: total #-pages- Adds an entry to the current
PageLog. The first form adds#-copiesto the"job-media-sheets-completed"attribute. The second form sets the"job-media-sheets-completed"attribute to#-pages.
- Adds an entry to the current
PPD: Keyword=Value [ ... KeywordN=Value ]โ Sets the named keywords in the printer's PPD file. This is typically used to update default option keywords such asDefaultPageSizeand the various installable options in the PPD file.STATE: printer-state-reason [ ... printer-state-reason ]STATE: + printer-state-reason [ ... printer-state-reason ]STATE: - printer-state-reason [ ... printer-state-reason ]- Sets, adds, or removes
"printer-state-reason"keywords for the current queue. Typically this is used to indicate media, ink, and toner conditions on a printer.
- Sets, adds, or removes
WARNING: messageโ Sets the"printer-state-message"attribute and adds the specified message to the currentErrorLogusing the"warning"log level.
๐ ENVIRONMENT VARIABLES ๐
The following environment variables are defined by the CUPS server when executing the filter:
CHARSETโ The default text character set, typically"utf-8".CLASSโ When a job is submitted to a printer class, contains the name of the destination printer class. Otherwise this environment variable will not be set.CONTENT_TYPEโ The MIME media type associated with the submitted job file, for example"application/postscript".CUPS_CACHEDIRโ The directory where semi-persistent cache files can be found and stored.CUPS_DATADIRโ The directory where data files can be found.CUPS_FILETYPEโ The type of file being printed:"job-sheet"for a banner page and"document"for a regular print file.CUPS_MAX_MESSAGEโ The maximum size of a message sent tostderr, including any leading prefix and the trailing newline.CUPS_SERVERROOTโ The root directory of the server.FINAL_CONTENT_TYPEโ The MIME media type associated with the output destined for the printer, for example"application/vnd.cups-postscript".LANGโ The default language locale (typicallyCoren).PATHโ The standard execution path for external programs that may be run by the filter.PPDโ The full pathname of the PostScript Printer Description (PPD) file for this printer.PRINTERโ The name of the printer.RIP_CACHEโ The recommended amount of memory to use for Raster Image Processors (RIPs).SOFTWAREโ The name and version number of the server (typicallyCUPS/major.minor).TZโ The timezone of the server.USERโ The user executing the filter, typically"lp"or"root"; consult thecups-files.conffile for the current setting.
๐ธ CONFORMING TO ๐ธ
While the filter interface is compatible with System V interface scripts, CUPS does not support System V interface scripts. periodt. ๐ โโ๏ธ
๐ง NOTES ๐ง
CUPS printer drivers and backends are deprecated and will no longer be supported in a future feature release of CUPS. Printers that do not support IPP can be supported using applications such as ippeveprinter(1).
CUPS filters are not meant to be run directly by the user. Aside from the legacy System V interface issues (argv[0] is the printer name), CUPS filters also expect specific environment variables and file descriptors, and typically run in a user session that (on macOS) has additional restrictions that affect how it runs. Unless you are a developer and know what you are doing, please do not run filters directly. Instead, use the cupsfilter(8) program to use the appropriate filters to do the conversions you need. ๐ซถ (fr fr, just use cupsfilter(8))
๐ SEE ALSO ๐
backend(7), cups(1), cups-files.conf(5), cupsd(8), cupsfilter(8), CUPS Online Help (http://localhost:631/help)
๐ COPYRIGHT ๐
Copyright ยฉ 2020-2024 by OpenPrinting.
and that's the whole page bestie ๐ this was brought to you by the CUPS crew, filter(7), dated 2021-02-28 โ go forth and convert some documents, you absolute icon โจ๐๐ฆ
๐ฆ where this page comes from
- alpine 3.22: cups-doc 2.4.18-r0 ยท Apache-2.0
- alpine 3.23: cups-doc 2.4.18-r0 ยท Apache-2.0
- alpine 3.24: cups-doc 2.4.19-r1 ยท Apache-2.0
- centos-stream 10: cups 1:2.4.10-18.el10 ยท Apache-2.0 WITH LLVM-exception AND BSD-3-Clause AND Zlib AND BSD-2-Clause
- debian trixie: cups 2.4.10-3+deb13u1 ยท Apache-2.0-with-GPL2-LGPL2-Exception
- debian trixie: cups 2.4.10-3+deb13u2 ยท Apache-2.0-with-GPL2-LGPL2-Exception
- fedora 43: cups 1:2.4.14-2.fc43 ยท Apache-2.0 WITH LLVM-exception AND BSD-3-Clause AND Zlib AND BSD-2-Clause
- fedora 43: cups 1:2.4.19-3.fc43 ยท Apache-2.0 WITH LLVM-exception AND BSD-3-Clause AND Zlib AND BSD-2-Clause
- fedora 44: cups 1:2.4.16-7.fc44 ยท Apache-2.0 WITH LLVM-exception AND BSD-3-Clause AND Zlib AND BSD-2-Clause
- fedora 44: cups 1:2.4.19-3.fc44 ยท Apache-2.0 WITH LLVM-exception AND BSD-3-Clause AND Zlib AND BSD-2-Clause
- nixpkgs unstable: cups 2.4.19
- opensuse-leap 16.0: cups 2.4.19-160000.2.1 ยท Apache-2.0
- opensuse-leap 16.0: cups 2.4.19-160000.2.1 ยท Apache-2.0
- opensuse-leap 16.0: cups 2.4.19-160000.2.1 ยท Apache-2.0
- opensuse-leap 16.0: cups 2.4.19-160000.2.1 ยท Apache-2.0
- ubuntu questing: cups 2.4.12-0ubuntu3
- ubuntu questing: cups 2.4.12-0ubuntu3.10
- ubuntu resolute: cups 2.4.16-1ubuntu1 ยท Apache-2.0-with-GPL2-LGPL2-Exception
- ubuntu resolute: cups 2.4.16-1ubuntu1.3 ยท Apache-2.0-with-GPL2-LGPL2-Exception
- ubuntu stonking: cups 2.4.16-1ubuntu3 ยท Apache-2.0-with-GPL2-LGPL2-Exception
- Copyright ยฉ 2020-2024 by OpenPrinting
- Copyright ยฉ 2007-2019 by Apple Inc
- Copyright ยฉ 1997-2007 by Easy Software Products
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms