How to add a fake, dummy, null printer in CUPS?
One solution is to install cups-pdf. It adds a virtual printer that writes PDF files. There are several tutorials on the web about how to install and configure it; since I use Gentoo, I've read Gentoo-wiki, which also mentions Sabayon wiki.
cups-pdf virtual printer has a configuration file in /etc/cups/cups-pdf.conf
, and by default all PDF files are written to /var/spool/cups-pdf/${USER}
.
(NB: On Ubuntu it writes to ~/PDF/)
There are a few limitations, though:
Since there is only one configuration file, multiple PDF printers will save to the same directory.
It is impossible to print "raw" data (using, for instance,
lpr -o raw
). Even sending a PDF file as a raw job will not work. Raw print jobs will generate a blank PDF file with just an empty page.
Even with these limitations, it works perfectly for my needs.
Footnote: if the user is using Gnome, or printing through a GTK+ application, then there is already a "Print to File" pseudo-printer at the print dialog. Thus, why should the user still want to add a virtual PDF printer? Here are a few reasons:
- That "Print to File" is specific to GTK+, and is not available for non-GTK+ applications. (maybe KDE has a similar feature, but I'm not sure)
- It makes possible to generate a PDF from Flash "applications" that were designed for printing. For instance, the PocketMod.
- Adding a virtual printer to CUPS makes it possible to test printing using shell scripts or other software that talks directly with CUPS. This is specially useful for developers while testing their applications.
- It is possible to "share" this virtual printer with the local network. Not exactly useful, but possible.
- It is possible to attach a post-processing command to be executed right after the PDF file has been saved.
The Cups Forum has a more complete/accurate answer to this question.
The answer is that the device URI should be set to file:/dev/null
So in my Ubuntu setup:
- Device URI: file:/dev/null
- Make and Model: Local Raw Printer
Which works for me perfectly.
I searched the Cups forum again and found this:
Commandline Null Printer Setup in Cups Forum
In your cupsd.conf:
FileDevice yes
Setup Printer
lpadmin -p nowhere -E -v file:/dev/null
Testing Printer
who |lp -d nowhere
You can create a printer that outputs to /dev/null
with lpadmin
:
$ sudo lpadmin -p myprinter -E -v file:///dev/null
This will be written to /etc/cups/printers.conf
, but you can also view printers with lpstat
:
$ sudo lpstat -s
myprinter accepting requests since Thu 22 Jan 2015 11:04:46 AM GMT
system default destination: myprinter
device for myprinter: ///dev/null
Note that you may need to enable FileDevice in /etc/cups/cupsd.conf on old Linux distros.
To make your new printer the default, use lpoptions
:
$ sudo lpoptions -d myprinter