Convert SVG's to PNGs. This works OK if the SVG's styles are inline. The SVG element must contain an xmlns attribute. Webkit also requires you specify a font size on `text` elements.
✓ Published0🌍 Public
CCaged
Last edited Jan 27, 2013
Created on Jan 27, 2013
This example shows a client-side workflow for converting an inline SVG graphic into a PNG image. It first serializes the SVG element—which must carry an `xmlns` attribute—into an XML string using `XMLSerializer`, then encodes that string as a base64 data URI. The code then creates a new `Image` object and assigns the data URI to its `src` attribute before appending the image to the document body. The approach relies on the browser’s native `btoa` function and works only if the SVG’s styles are inline, and WebKit browsers additionally require an explicit `font-size` on text elements.
AI-generated description