Skip to content

Instantly share code, notes, and snippets.

@hollodotme
Last active October 15, 2017 22:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hollodotme/1c70596a144a9a3d0aad2b3626736d6e to your computer and use it in GitHub Desktop.
Save hollodotme/1c70596a144a9a3d0aad2b3626736d6e to your computer and use it in GitHub Desktop.
OS X Finder service for converting PDF to SVG via convert.io

Install convert.io CLI client

See here.

Create an API key for convert.io

See here.

Create a Finder service to convert PDF to SVG files

  1. Start Automator
  2. Create a new Service
  3. Select "Service reveives selected [PDF files]" in "Finder.app"
  4. Add a new "Run shell script" from the "Utilities" section in the Library sidebar
  5. Select your preferred shell and select "Pass input [as arguments]" in the upper right select field
  6. Copy the following code for the shell script:
realpath() {
    [[ $1 = /* ]] && echo "$1" || echo "$PWD/${1#./}"
}

LOGFILE="/path/to/convert-pdf-to-svg.log"
API_KEY="<YOUR-CONVERT-IO-API-KEY>"

for f in "$@"; do
        BASEDIR=$(dirname "$f")
        REALDIR=$(realpath "${BASEDIR}")
	echo "$f" >> ${LOGFILE}
        /usr/local/bin/convertio -f svg -o "${REALDIR}" --apikey ${API_KEY} "$f" >> ${LOGFILE} 2>&1;
done

Save the service under e.g. "Convert to SVG (via convert.io)"

Now right-click on a PDF file in finder and click on "Services" > "Convert to SVG (via convert.io)". The SVG file should be created in the same directory as the PDF file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment