- macOS/Mac OS X (tested only on El Capitan, but should work on Sierra and older versions)
- Xcode Command Line Tools / Xcode
- Homebrew (http://brew.sh/)
- svg2pdf (via Homebrew)
- Poppler (via Homebrew)
- For installing Xcode and Command Line Tools. Please see: http://railsapps.github.io/xcode-command-line-tools.html
- Open up your Terminal.app (or iTerm.app)
- Follow the instructions at http://brew.sh or just Copy Paste: (one line!)
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
to install Homebrew. - Install Poppler (that we need for the
pdftops
command) by copy paste:brew install poppler --with-little-cms2
(It will install dependencies also, which could take a minute or so). - Install svg2pdf by copy paste:
brew install svg2pdf
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew install poppler --with-little-cms2
brew install svg2pdf
- Open up Automator.app located in your Applications folder.
- Choose ”Service” in the dialog sheet when creating a new document.
- In the
Services receives selected:
menu at the top of the ”Canvas” on the right, change toimage files
and ”in” toFinder.app
- In the sidebar to the left, search for
Run Shell Script
- Drag the
Run Shell Script
action to the ”canvas” on the right side. - At the right in the
Run Shell Script
action, change thePass input
fromto stdin
toas arguments
- Copy Paste this into the action text box (remove existing code in the text box):
PATH=/usr/local/bin:/bin export PATH
for f in "$@"
do
svg2pdf "$f" "${f%.*}.pdf";
pdftops -eps "${f%.*}.pdf";
rm -f "${f%.*}.pdf"
done
Save the Service into /Users/yourusername/Library/Services
. Test it by select a .svg
file in the Finder and Right-Click
and go to end at the Context menu labeled ”Services” and look for the name you gave your Service. If everything works alright,
.eps
versions of the .svg
file(s) choosen should appear.
Line 1: PATH=/usr/local/bin:/bin export PATH
Tells where to look for svg2pdf
and pdftops
This may not be necessary depending to your enviroment settings.
Line 4: svg2pdf "$f" "${f%.*}.pdf";
Converts the svg
-file(s) to PDF. The ;
at the end indicates when the command is finished, go ahead and jump to the next command.
Line 5: pdftops -eps "${f%.*}.pdf";
Converts the pdf
-file(s) to EPS.
A small workaround. I never managed to get Inkscape (command line) working correctly on macOS/Mac OS X.
Line 6: rm -f "${f%.*}.pdf"
Deletes the pdf
file(s) leaving you with the original svg
file(s) and the eps
files you created.
You could remove this line. That way you have both a EPS version of the svg
files(s), and a vector PDF version. Or you could add svg
to delete the original files as well (however, i would not recommend that).
Some conversions could in some cases output .eps
file(s) that don't necessarily match the .svg
file(s) by 100%. In my tests,
most files converted worked out just fine except a few (the eps output itself was correct, but was ”squeezed” a little bit).
Getting creative with naming the Service. You could use a Emoji or Unicode symbol in the beginning of the file name. While it's not best practice in the *
-nix or Windows world (or anywhere else), this is Mac only and for your personal use, also it will not give you any kind of problems (if you send it to someone, do zip
the file first!). Example: EMOJI - Vector | SVG 2 EPS
. Makes it easier to locate in the sometimes crowded ”Services” Contextual menu.
Example (from my SVG2PNG Service):