@mocanvas/editor · function
declare function getSvgAsImage(svgString: string, options: GetSvgAsImageOptions): Promise<Blob | null>Rasterise an SVG.
The SVG is loaded into an Image and drawn to a canvas, which is the only
way to get the browser's own SVG renderer to produce pixels. That means the
markup must already be self-contained: an Image loading an SVG gets no
access to the page's stylesheets, fonts or cookies, so anything left as an
external reference simply does not appear.
Resolves null when there is no DOM to do it in, or when the browser refuses
the image — a caller that wanted a picture and got nothing can fall back to
offering the SVG itself.
mocanvas is built by Symbio. Free for non-commercial, non-profit and development use; commercial use needs an agreement. Not affiliated with or endorsed by tldraw.