Converting MetaPost to Scalable Vector Graphics (SVG)

This page demonstrates the process of converting MetaPost into SVG. The premise of this procedure relies heavily on first converting MetaPost to PDF (in order to ensure proper font embedding). Once this has been accomplished, the conversion from PDF to SVG is straightforward using the tool below.

To demonstrate this conversion, consider the following MetaPost source file:
   draw fullcircle scaled 72;
   draw bbox currentpicture withcolor background;

Running mpost on will generate a single output file foo.1 which is (for all practical purposes) an Encapsulated PostScript file. This output looks like :



Instead of creating an EPS, we will create a PDF output file using mptopdf (by Hans Hagen). This command should be included in virtually all respectable TeX distributions. The syntax is as follows:


This command should generate a PDF version of the above graphic called foo-1.pdf. We then place foo-1.pdf in the PDF to SVG converter below to generate the SVG image foo-1.svg.


PDF can be no larger than 1 Mbytes

The (behind the scenes) process of converting the PDF to SVG above uses pdf2svg which relies on Cairo and Poppler.