download an svg element as an SVG or PNG file, including CSS defined styles
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
demo
lib Using np May 8, 2017
src Style fixes May 8, 2017
test
.gitignore New features and improved demo Apr 25, 2017
.npmignore Adding browser files to npm publish Oct 3, 2015
.travis.yml Only need to test latest node Apr 26, 2017
.zuul.yml Fix bug introduced in v8 and tests Apr 26, 2017
API.md New features and improved demo Apr 25, 2017
CHANGELOG.md v0.9.0 May 8, 2017
LICENSE.md
README.md Added travis badge Oct 29, 2015
bower.json Use computed-styles Oct 27, 2015
browser.js Using np May 8, 2017
browser.min.js Fix duplicated xmlns in IE 11 #7 May 8, 2017
esdoc.json asSvg and asPng now return SvgSaver instance Sep 30, 2015
index.js
package.json v0.9.0 May 8, 2017
todo.md Use FileSaver as a dep May 8, 2017
yarn.lock Using np May 8, 2017

README.md

svgsaver

Download an SVG element as an SVG or PNG file, including CSS defined styles.

NPM version Downloads Downloads

Build Status Codacy Badge

js-semistandard-style License

Features

  • Download <svg> by element object.
  • Download as SVG or PNG file.
  • Copies SVG element styles as rendered in the browser, including styles defined in CSS style sheets.
  • Copies only SVG relevant and non-default styles. See here.
  • Computed styles are in-lined for maximum compatibility.

Install

Node

npm install svgsaver

Bower

bower install svgsaver

JSPM

jspm install svgsaver=npm:svgsaver

Usage

For maximum compatibility across browsers include eligrey/FileSaver.js/ and eligrey/canvas-toBlob.js. See Compatibility-Chart for more information.

Example

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

Demos

Acknowledgments

Based on previous work on Hypercubed/angular-downloadsvg-directive. Some portions of this code inspired by raw and moagrius/copycss.

License

MIT License