Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm writing a piece of software that supports multiple printers. In order to test it, I need to add multiple printers to my CUPS server. How can I do that?

I want to add a few fake printers that will send the jobs directly to /dev/null. That way, I can watch the "completed jobs" list in CUPS interface and observe if my software is using the correct printer for each job.

share|improve this question

migrated from stackoverflow.com Jun 30 '11 at 20:11

This question came from our site for professional and enthusiast programmers.

    
isnt this correct "lpadmin -p lp0 -E -v /dev/null -m raw" –  umanga Jul 30 '12 at 5:09
add comment

2 Answers

up vote 3 down vote accepted

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.
share|improve this answer
add comment

The Cups Forum has a more complete/accurate answer to this question.

Link to answer in The Cups Forum.

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.

share|improve this answer
    
I am just looking at my printout now: fine details, vibrant colours it plain jumps off the page at me. ... hey waitaminute .... –  Andrew Russell Mar 13 '12 at 22:42
    
Link seems broken. :( –  Denilson Sá Mar 14 '12 at 1:10
    
Thank you. I needed a dummy printer in my Virtual Machine to screenshot some instructions. :) –  njallam Aug 24 '12 at 18:58
    
The Link is now fixed –  Andrew Russell Mar 1 '13 at 1:24
1  
Link is broken again. –  Rob Feb 18 at 15:29
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.