fabric.Canvas Class
Canvas class
Methods
-
[options]
-
[reviver]
Returns SVG representation of canvas
Parameters:
-
[options]
Object optionalOptions object for SVG output
-
[reviver]
Function optionalMethod for further parsing of svg elements, called after each fabric object converted into svg representation.
Returns:
SVG string
Example:
Normal SVG output var svg = canvas.toSVG();
SVG output without preamble (without <?xml ../>) var svg = canvas.toSVG({suppressPreamble: true});
SVG output with viewBox attribute var svg = canvas.toSVG({ viewBox: { x: 100, y: 100, width: 200, height: 300 } });
SVG output with different encoding (default: UTF-8) var svg = canvas.toSVG({encoding: 'ISO-8859-1'});
Modify SVG output with reviver function var svg = canvas.toSVG(null, function(svg) { return svg.replace('stroke-dasharray: ; stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 10; ', ''); });