Create a 'PostScript to file' CUPS print queue

May 29, '09 07:30:02AM

Contributed by: Anonymous

I came across this page, an archive of a mailing list post written by Kurt Pfeifle, that gives detailed instructions on how to print PostScript to a file by creating a CUPS backend using a shell script.

It took me ages to find, so I thought it should be more prominently featured. Here's what Kurt has to say about the process:

You can enable a very simple file:/ backend by putting FileDevice Yes into cupsd.conf. However it will not allow raw printing of application/octet-stream files. And the second job will overwrite the first one (because you need to give a filename to the backend, in the device URI, like file:/tmp/print.prn)

You could write your own CUPS backend. Here are the rules for that: You can write it in Bash, Perl, C, Python or whatever you like. A very simple "filewrite" backend looks like this:
#!/bin/bash
TARGETFILE=${DEVICE_URI#filewrite:}1
if [ $# -eq 0 ]; then
echo "direct filewrite "Unknown" "Print any job to file specified in device-URI""
exit 0
fi
cat $6 > $TARGETFILE
A more advanced one is here...
[robg adds: The code for the advanced backend is quite long, and I'm not certain of the copyrights, so I don't want to duplicate it in whole here. For those interested, please see the linked page for the more complex script. Note that I've formatted the quoted section above, for easier reading, but didn't change any of the content.]

Comments (3)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20090527074203125