Printing Postscript via lpr on Jaguar

What is it for?

There is one little hole in the model of printing under OS X that needs to be filled so that one can seamlessly print from Unix style applications. That little hole is printing Postscript via the lp or lpr commands.

Will it work for you?

Several people have tried out this little hack and it has worked flawlessly for them but it looks like there is one configuration which won't work. If you have even one Postscript printer defined in your printers list CUPS will break. Now I personally have not been able to reproduce this bug and it goes against everything they say in the documentation but nonetheless this appears to be the case. The good news is that once 10.3 is released we will have native Postscript support and this hack will not be necessary.

Do you have Ghostscript?

First you need to have Ghostscript installed which includes the ps2pdf command that does the real work. I will assume that you are using a default fink setup but if that is not the case you only need to change the pstopdf script below to point to the correct locations on your machine. A quick way to see if you may have problems is to enter locate ps2pdf in the terminal. On my machine this produces the following results

[Omppu:~] eric% locate ps2pdf
/sw/bin/ps2pdf  <-- Bingo
/sw/bin/ps2pdf12
/sw/bin/ps2pdf13
/sw/bin/ps2pdfwr
/sw/share/man/man1/ps2pdf.1
/sw/share/man/man1/ps2pdf12.1
/sw/share/man/man1/ps2pdf13.1
/sw/share/man/man1/ps2pdfwr.1

Download the Files

Now that we know you have Ghostscript installed all you need to do is download two little files. The first one spud.convs tells CUPS how to convert Postscript documents into PDF documents using our new script. The second file is the conversion script itself pstopdf.

Safari appended a .txt to those files when I tried to download them so you will need to make sure that you change the commands below to match what your browser does in case it calls them something else. It is important that when the files are copied to their actual locations that they are named spud.convs and pstopdf.

Copy and Install

Now in a terminal enter the following commands to put everything in the right location and make sure that the filter is executable. You will need to adjust the paths below a little to match your system. A neat trick for inserting the path of one of the files you downloaded is to drag and drop it onto the terminal window.


[Omppu:~] eric% sudo cp /Users/eric/Desktop/spud.txt /etc/cups/spud.convs 
[Omppu:~] eric% sudo cp /Users/eric/Desktop/pstopdf.txt /usr/libexec/cups/filter/pstopdf
[Omppu:~] eric% sudo chmod +x /usr/libexec/cups/filter/pstopdf

Once this is done you have to give CUPS a little kick to tell it things have changed, if you are lazy you can reboot at this point if you are impatient you can just send the process a HUP signal like this using the process ID of your cups daemon.


[Omppu:~] eric% ps -aux | grep cupsd
root   383   0.0  0.1     3268    772  ??  Ss    7:46AM   0:02.50 /usr/sbin/cupsd
eric   579   0.0  0.0     1116      4 std  R+   12:15PM   0:00.00 grep cupsd
[Omppu:~] eric% sudo kill -HUP 383

At this point you should be good to go. As a quick test you can print the CUPS test page via lpr by typing lpr /usr/share/cups/data/testprint.ps into the terminal.

Good Luck! Let me know of any problem you have and I'll update this page with the fixes.


Eric
Last modified: Thursday, September 11th, 2003

The folks at www.digits.com say that other people have taken a gander at this page.