Apple - Is there a free command line program for converting PDF files to SVG?

Turns out Inkscape has a command line mode. I added this to .bash_profile:

alias inkscape="/Applications/Inkscape.app/Contents/Resources/bin/inkscape"

and now this command converts from PDF to SVG:

inkscape Logo.pdf --export-plain-svg=Logo.svg

Unfortunately, the current version of Sketch has very rudimentary SVG import capabilities and can't correctly read any of the files I've made even though they display fine in Opera and OmniWeb. The company says future versions will do better.


My own research has so far led me thus:

There is a command line tool called PDF2SVG, which would be ideal, but it requires you to build it yourself and install all the necessary dependencies, including two libraries, Cairo and Poppler. (I tried installing Cairo, but it wanted pkg-config, which in turn reported that some other library was missing....)

The only decent tool I've found is MuPDF, which contains a CLI utility called mutool. You still have to build it yourself, but it is at least self-contained.

Download the source code;
unzip the package,
in the Terminal type cd (followed by a space),
then drag the unzipped folder from the Finder into the Terminal window.

Press Enter. Then type sudo make prefix=/usr/local install and enter your password.

You can then delete the source code.

Then you can convert PDFs to SVG using such commands as:

mutool convert -F svg -o filename.svg inputfile

If there are multiple pages, the page number will be appended to each filename. Either the -F flag or the -o flag is optional. But not both.

MuPDF is made by the people who make GhostScript, so should be reliable.