How to convert a PDF file to SVG on the command line

If you want to convert my.pdf to my.svg, use eps2svg like this:

eps2svg my.eps

Even though the name eps2svg may suggest it can only read EPS files, the program will handle PDFs just fine!

This command produces my.svg – note that if my.svg already exists, eps2svg will create my_1.svg, my_2.svg and so on and will not overwrite my.svg!

You can also use this shell function:

function pdf2svg { eps2svg "${1%.*}.eps" "${1%.*}.svg" ; }

This will always produce my.svg, overwriting it if it already exists!

Usage example:

pdf2svg my.pdf # Produces my.svg