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:
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)[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.]
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:
- make sure it can read from SDIN and write to STDOUT
- make sure if called with zero arguments it responds with a message similar to the other backends (see how they do it)
- make sure it takes the 5 or 6 arguments all CUPS filters and backends take in the same order, i.e. backendname job-id user title copies options [job-file]
- put it into /usr/lib/cups/backend/ and restart cupsd (check if it is recognized with lpinfo -v)
A more advanced one is here...#!/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
•
[13,360 views]

