Printing

CUPS - Common UNIX Printing System





CUPS Process

After a print command execution:
  1. The scheduler validates the command and processes the print job:
    • Creates job files according to the settings specified in the configuration files.
    • Records activities in the log files.
  2. Job files are processed with the help of the filter, printer driver, and backend, and then sent to the printer.

Scheduler

Scheduler manages:
  • Print jobs
  • Handles administrative commands
  • Allows users to query the printer status
  • Manages the flow of data through all CUPS components

Mainly 2 files under /etc/cups/ directory:
  • cupsd.conf
    System settings, no printer details. Mainly network security.
  • printers.conf
    Printer settings.

Job Files

The instances to print are in the form of print requests stored in files under /var/spool/cups/.
Those files are put into a Print Queue and removed after printing. They are of 2 types:
  • Data files, starting with the letter d.
  • Control files, starting with the letter c.

Log files

Store in /var/log/cups

Filters, Printer Drivers, and Backends

  1. Job files are converted in printable format by filters.
  2. Printer drivers are contained in /etc/cups/ppd/ directory.
  3. The print data is then sent to the printer through another filter, and via a backend that helps to locate devices connected to the system.

Managing CUPS

To use CUPS, CUPS daemon need to be activated and properly managed:
  1. $ systemctl status cups
  2. $ sudo systemctl [enable|disable] cups
  3. $ sudo systemctl [start|stop|restart] cups
A webserver is already provided by CUPS at the address http://localhost:631.

Commands for printing

$ lp <filename>
To print the file to default printer

$ lp -d printer <filename>
To print to a specific printer (useful if multiple printers are available)

$ program | lp
or
$ echo string | lp
To print the output of a program

$ lp -n number <filename>
To print multiple copies

$ lpoptions -d printer
To set the default printer

$ lpq -a
To show the queue status

$ lpadmin
To configure printer queues

Print management commands

$ lpstat -p -d
To get a list of available printers, along with their status

$ lpstat -a
To check the status of all connected printers, including job numbers

$ cancel job-id
or
$ lprm job-id
To cancel a print job

$ lpmove job-id newprinter
To move a print job to new printer


Utilities

PS/PDF conversion:
  • pdf2ps / ps2pdf
  • enscript
  • pstopdf / pdftops
  • convert
  • gm convert

PDF visualisation:
  • evince
  • okular

PDF manipulation:
  • qpdf
  • pdftk
  • ghostscript

Extra:
  • pdfinfo
    Extracts information

  • flpsed
    Adds data such as comments

  • pdfmod
    GUI for the operations

Comments