Install the cups-pdf package on a server, then restart cups using /etc/init.d/cups restart. This should add a “printer” that prints to a file. Using either the web or CLI interface, you should be able to find the printer.
If you use the web interface (https://10.0.2.15:631/admin), click the “Administration” tab, then click “Find New Printers”. “Virtual PDF Printer (CUPS-PDF)” should appear, with a button captioned “Add This Printer” to its left. Click the button, and you’ll be prompted several fields to identify and describe the printer.
The web interface of CUPS will try to use HTTPS to make sure your authentication information is encrypted. You will need to accept the certificate as an exception because it is not signed by a certificate authority.
The next screen asks you about the “Make” of the printer or supply a PPD file. A PPD file is essentially a file that specifies how to translate Postscript to a language that the printer understands. In this case, select “Generic” for “Make”, click “Continue”.
Next, Select “Generic CUPS-PDF Printer (en)”. This correctly identifies the printer. Next, click “Add Printer”. When the printer is added, you need to have privileged access. Furthermore, When asked to authenticate, you need to authenticate as root and supply the password of root accordingly.
If the authentication is successful, then the printer will be added successfully.
Now you can click the “Administration” tab again, we can now control whether the printer is to be shared. If you check “Share published printers connected to this system” and “Allow printing from the Internet”, then the CUPS-PDF printer will be shared via the network. Click “Change Settings” to confirm the changes. The web interface will automatically restart CUPS to make the changes effective.
Now, if you run lpinfo -v (as root) on another computer of the same subnet, you should see a line similar to the following:
This shows that the “printer” is, in fact, visible to other computers of the network. The strange %20 is an escape of the space character, and %40 is the escaped version of the at symbol (@).
The published name of the PDF printer is CUPS-PDF, unless you changed that when you configured it differently. You can now print from a client. You should install cups-bsd on a client computer so that the client program lpr is installed.
On a client computer, create a regular text file with some simple content, call it test.txt. Then, execute the following command:
This command specifies the printer name with the -P option and the server IP address with -H. You can check to see if the command is successful using the following command:
Note that the server host is specified by the -h (lower case ‘H’) option.
So where is the file printed? Well, that depends. If the user of the client machine (the one who runs lpr) also exists on the server, then the PDF document is created in the PDF subfolder of the home directory of that user. However, if the user of the client machine running lpr does not exist on the server, then the PDF document is located in /var/spool/cups-pdf/ANONYMOUS.