MetaPost To SVG

From Svg wiki

MetaPost is a graphics programming language based on Don Knuth's METAFONT, with some PostScript output and facilities for including typeset text.

One way to convert MetaPost graphics to SVG format is described by Troy Henderson.

Prerequisites for making this conversion require that the graphic be in PDF (e.g., use mptopdf) to preserve fonts and then use pdf2svg (by David Barton) to convert the PDF to SVG.

Note that pdf2svg requires both Cairo and Poppler. Detailed instructions for this MetaPost to SVG conversion may be found at http://www.tlhiv.org/MetaPost/tools/mptosvg, which includes an online converter for PDF to SVG. Furthermore, Henderson has a MetaPost Previewer that allows users to enter MetaPost code and have the output convert to SVG on the fly. The syntax for converting a PDF (say, "foo.pdf") to SVG using pdf2svg would be

pdf2svg foo.pdf foo.svg 1


Henderson notes that another fine method for converting PDF to SVG, which does not require pdf2svg, involves the following two steps:

pstoedit -page 1 -dt -psarg "-r9600x9600" -f sk foo.pdf foo.sk
inkscape -z -f foo.sk -l foo.svg

where pstoedit and Inkscape are free available.