11

I have some eps files that I would like to convert to PDF. I used to be able to open these in Preview, but Apple has removed the ability of Preview to open EPS files in Ventura.

4 Answers 4

14

macOS has a command line pstopdf that will work with both ps and eps files.

pstopdf <filename>.ps

will produce <filename>.pdf.

man pstopdf for more details.

1
  • 2
    This tool is not included anymore in latest versions in Sonoma Nov 23, 2023 at 9:47
4

Probably the easiest way to get the ps2pdf utility back in Sonoma and forward is by installing ghostscript via Homebrew

brew install ghostscript

Here's an example (create a PDF of the ls manpage)

man -t ls | ps2pdf - /tmp/ls.pdf &&
open -b com.apple.Preview /tmp/ls.pdf
1

I discovered this after updating macOS yesterday. Thanks to @dmaclach’s answer, I found PostScriptToPDF by Edward Mendelson, which is a wrapper for pstopdf as an AppleScript application. This offers a few conveniences, namely: an “Open” dialog, drag & drop, and file type associations—if you associate it with .ps files in Finder (under “Open With” in the contextual menu or “Get Info” panel) then double-clicking a PostScript file will quietly convert it to PDF.

Note that PostScriptToPDF will request permission to control “System Events”, which is no cause for alarm—that’s an application provided by Apple so that AppleScript programs can perform folder actions on your behalf. In this case, it allows the option of automatically deleting the PS file after successful conversion. You can deny the request without issue if you won’t use that feature.

0

(This is sort of a combination of the answers from @dmaclach and @luckman212.)

pstopdf --- This is a Ventura 13.x utility, which apparently is not available in Sonoma 14.x. I tried it, but it filled the stdout with output from the conversion that I didn't need to see. Use pstopdf -l to hide the excess output by sending it to a log file somewhere.

ps2pdf --- This is a script to run ghostscript or gs, which you can install with Homebrew following the instructions from @luckman212. I think mine was installed by MacPorts, so that is could be an option if you don't use Homebrew. One issue for me was that default ps2pdf made a lot of extra whitespace around my image, apparently because default ghostscript assumes a full page size for the output PDF. Using a StackOverflow tip, I found that ps2pdf -dEPSCrop sizes the output PDF nicely, just like the result from Apple's ephemeral pstopdf command.

Multiple files: Both of these methods work for single files. But the question title is about "converting... files to pdf". I was able to convert all the eps files in my directory at once using a single command:

find . -type f -name '*.eps' -exec ps2pdf -dEPSCrop {} \;

The command above is thanks to @luckman212, who found that my first attempt (below) was awkward and could lead to issues with some filenames.

ls *eps | awk '{system("ps2pdf -dEPSCrop " $0)}' -
1
  • 1
    It's usually bad practice to pipe output from ls, and you can run into problems with globbing and spaces in filenames. Also, that's a strange use of awk. I think this is more robust and straightforward: find . -type f -name '*.eps' -exec ps2pdf -dEPSCrop {} \;
    – luckman212
    Apr 27 at 0:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .