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
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.
- 397
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
- 309
- 2
- 7
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.
- 156
(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)}' -
- 141