Printing to a File

Kurt Pfeifle kurt.pfeifle at
Tue Jun 19 21:03:04 PDT 2007

> Hello,
> I'm trying to do something that I thought would be very simple, that is,
> setup a cups printer that will just dump it's output to a file.
> The reason I'm doing this is that I have a program that prints to a
> Zebra barcode printer.  However the program isn't working and I want to
> see exactly what my program is sending to the printer.  I tried to
> create a RAW local printqueue that points to /tmp/foo or some such
> thing.  I restarted cups but it doesn't work, nothing ever goes into the
> file.

This is not the correct approach, for 2 reasons:

 (1) printing the job as "raw" would not give you much info. Raw jobs
     byepass the CUPS filtering queue and end up at their destination
     completely un-modified

 (2) the builtin file:/ backend in CUPS is purposefully not supporting
     raw printing AFAIR (for security reasons).

You have to write your own "2file" backend and use that. Try this one (it is purposefully made more explicit than required):

--------------------- snip -------------------------------------------
# /usr/lib/cups/backend/2file
# (c) 2007  Kurt Pfeifle <pfeifle at>


case ${#} in
           echo "direct 2file \"Unknown\" \"2file backend to test filtering\""
           exit 0
           cat - > ${DEVICE_URI#2file:}
           cat ${6} > ${DEVICE_URI#2file:}
           echo "Usage: 2file job-id user title copies options [file]"
           exit 0

--------------------- snip -------------------------------------------

HOWTO use it:

 (1) Copy to /usr/lib/cups/backend/2file and make it executable
 (2) Install printer like this:
     lpadmin -p fileprinter -v 2file:/path/to/file/output.prn -E -P /path/to/PPD.ppd
 (3) Each job will end up in /path/to/file/output.prn; new jobs will
     overwrite the previous one.

Make sure that /path/to/file/ exists and is writeable for whatever user your cupsd runs as....

More information about the cups mailing list