TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Inspired by these questions—

—how can one convert a PSTricks animation to an animated SVG image?

SVG animation would be nicer than GIF because SVG is a vector format that supports smooth animations and arbitrary colors.

share|improve this question

there is a pdf2svg available for Linux by the distribution or from http://www.cityinthesky.co.uk/opensource/pdf2svg But I didn't tried it for an animation.

share|improve this answer
That tool is essentially leveraging Cairo, and Cairo doesn't do animation by itself at all. From another similar converter also based on Cairo (called CairoSVG, which also has a pdf2svg script, but it's not the same program as aforementioned one) "No animations are supported in CairoSVG" (cairosvg.org/svg_support/#idabout-svg). So it's a hail Mary that the other pdf2svg program would do SMIL (there's nothing about animations either way in its scant documentation.) SMIL is also not part of SVG in any way; it can even animate HTML, so assuming that SVG implies SMIL is not a good bet. – Fizz Aug 3 '14 at 16:13
I've tried the example from tex.stackexchange.com/questions/73545/… with that cityinthesky pdf2svg and I only get the first frame/page in the SVG. Which was rather predictable not only because the docs non-mention of animation, but also because the way PStricks does PDF "animation" is not real PDF animation, so imagemagick basically has a hack for composing actual animation from the pdf pages, which are a static document. Real PDF animation is scripted as in ctan.org/tex-archive/macros/latex/contrib/animate or embeds Flash (SFW). – Fizz Aug 3 '14 at 16:43

The only way I can answer what you asked is: currently not possible, unless you write (or commission) the [extra] software needed.

Some alternatives that I use(d) for web animations:

Bonus update: Apparently there is a way to convert SWF to SVG+SMIL using MP4Box; see http://www.slideshare.net/cconcolato/streaming-of-svg-animations-on-the-web from slide 10 onward. I've just discovered that presentation, so I have no idea how well that works in practice.

Update2: It seems that the only TeX engine that has native support for SVG animations is BaKoMa, which ain't free: http://www.bakoma-tex.com/menu/svgwrite.php (The svg.sty discussed there is not the one from CTAN, but a proprietary one, which depends on SVG specials on the backend/driver that no free TeX seems to provide.) They have a demo with mostly gratuitous animations at http://www.bakoma-tex.com/samples/svgtour.svg. I would have liked to see something more useful done with that... (For the sake of completeness, the non-free version of VTeX 8 also claims some kind of support for SVG animations, again using their own specials. The examples at http://www.micropress-inc.com/svg.htm don't work out of the box on modern browsers, and VTeX itself hasn't been updated in almost a decade, so I'm not really going to try to figure out what's wrong with their examples. Looking at the source code of the SVG they generate, it seems they use Javascript for the SVG animations, unlike BaKoMa which uses SMIL, at least in the first slide of their demo.)

Practical update(3): Well, I had no trouble converting the pdf resulting from How to convert pstricks animation to GIF file? to a SWF (via pdf2swf), and it plays fine in a web browser, however getting MP4box to do anything other than crash on the resulting SWF has been a challenge insofar. You may want to stay tuned to https://sourceforge.net/p/gpac/discussion/287547/thread/ee0d387d/

I had no trouble converting the SWF with Google Swiffy (https://www.google.com/doubleclick/studio/swiffy/) though, which generates SVG (at render time, the storage format is JSON) but with Javascript for animations (and the runtime conversion from JSON to SVG). The following excerpt from the Swiffy thesis is generally relevant for converting key-frame animations to SVG:

The choice of SVG for rendering leaves us with several options to animate the SVG content. At first sight, both CSS animation and SMIL, adhere to our design goal of using a declarative representation when possible. However, both technologies provide insufficient control over the animation when support for ActionScript scripting is required. For example, although the concept of keyframes exists in CSS animation, it does not provide a mechanism to synchronise the JavaScript code to those keyframes or to modify the timeline from JavaScript, which is a basic feature required for SWF compatibility. Another limiting factor is that animation in the SWF file itself is not defined in terms of high-level transitions, but defines the position of every object at specific keyframes. Mapping these definitions back onto CSS or SMIL transitions is not always possible. Finally, these standards are not widely available: The CSS animation specification is still in working draft state, while SMIL is not implemented in the Internet Explorer browser We have therefore chosen to use JavaScript to animate SVG on the client. Although this imperative approach might be less efficient, the level of control it provides is required to match all SWF functionality.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.