Home Identifier Source Test Repository
import {SvgSaver} from 'svgsaver/src/svgsaver.js'
public class | source

SvgSaver

Constructor Summary

Public Constructor
public

constructor(opts: *)

SvgSaver constructor.

Method Summary

Public Methods
public

asPng(el: SVGElement, filename: string): SvgSaver

Saves the SVG as a PNG file using method compatible with the browser

public

asSvg(el: SVGElement, filename: string): SvgSaver

Saves the SVG as a SVG file using method compatible with the browser

public

getBlob(el: SVGElement): Blog

Return the SVG, after cleaning, as a text/xml Blob

public

getHTML(el: SVGElement): String

Return the SVG HTML text after cleaning

public

getUri(el: SVGElement): String

Return the SVG, after cleaning, as a image/svg+xml;base64 URI encoded string

Public Constructors

public constructor(opts: *) source

SvgSaver constructor.

Params:

NameTypeAttributeDescription
opts *

Example:

var svgsaver = new SvgSaver();                      // creates a new instance
var svg = document.querySelector('#mysvg');         // find the SVG element
svgsaver.asSvg(svg);                                // save as SVG

Public Methods

public asPng(el: SVGElement, filename: string): SvgSaver source

Saves the SVG as a PNG file using method compatible with the browser

Params:

NameTypeAttributeDescription
el SVGElement

The element to copy.

filename string
  • optional

The filename to save, defaults to the SVG title or 'untitled.png'

Return:

SvgSaver

The SvgSaver instance

public asSvg(el: SVGElement, filename: string): SvgSaver source

Saves the SVG as a SVG file using method compatible with the browser

Params:

NameTypeAttributeDescription
el SVGElement

The element to copy.

filename string
  • optional

The filename to save, defaults to the SVG title or 'untitled.svg'

Return:

SvgSaver

The SvgSaver instance

public getBlob(el: SVGElement): Blog source

Return the SVG, after cleaning, as a text/xml Blob

Params:

NameTypeAttributeDescription
el SVGElement

The element to copy.

Return:

Blog

SVG as a text/xml Blob

public getHTML(el: SVGElement): String source

Return the SVG HTML text after cleaning

Params:

NameTypeAttributeDescription
el SVGElement

The element to copy.

Return:

String

SVG text after cleaning

public getUri(el: SVGElement): String source

Return the SVG, after cleaning, as a image/svg+xml;base64 URI encoded string

Params:

NameTypeAttributeDescription
el SVGElement

The element to copy.

Return:

String

SVG as image/svg+xml;base64 URI encoded string