Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Create a 'PostScript to file' CUPS print queue Printers
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:
  • 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)
You can write it in Bash, Perl, C, Python or whatever you like. A very simple "filewrite" backend looks like this:
if [ $# -eq 0 ]; then
echo "direct filewrite "Unknown" "Print any job to file specified in device-URI""
exit 0
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.]
  • Currently 2.63 / 5
  You rated: 3 / 5 (8 votes cast)

Create a 'PostScript to file' CUPS print queue | 3 comments | Create New Account
Click here to return to the 'Create a 'PostScript to file' CUPS print queue' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Create a 'PostScript to file' CUPS print queue
Authored by: Doc Drang on May 29, '09 10:06:38AM

Isn't it easier (and almost as fast) to just use the "Save as PostScript…" item from the PDF popup menu in the Print sheet?

Doc Drang

[ Reply to This | # ]
Create a 'PostScript to file' CUPS print queue
Authored by: leamanc on May 29, '09 11:40:22AM

Yes, it is easier to do that, and pretty much just as fast if you are in front of the computer doing File->Print operations.

But the point of doing something like this would be for batch jobs, automation, scripting output, etc.

[ Reply to This | # ]
Create a 'PostScript to file' CUPS print queue
Authored by: daleminter on May 29, '09 10:09:47PM
I just use the CUPS-PDF installer found here:

Install the package file
Add Printer in System Prefs / Print & Fax
Ensure "Default" tab is selected in the toolbar
Select CUPS-PDF from list
Select Print Using: / Select a driver to use...
Choose "Generic postscript color printer, rev3a"
Click Add

Tecsol Limited
Auckland, New Zealand

[ Reply to This | # ]