svgsaver

download an SVG element with css styles

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
svgsaver
5940.9.07 years ago9 years agoMinified + gzip package size for svgsaver in KB

Readme

svgsaver
Download an SVG element as an SVG or PNG file, including CSS defined styles. !NPM versionnpm-badgenpm !Downloadsdownload-badgenpm !Downloadsbower-badge !Build Statustravis-imagetravis-url !Codacy Badgecodacy-badgeCodacy !js-semistandard-stylestandard-badgesemistandard !Licenselicense-badgeMIT 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

```js npm install svgsaver ```

Bower

```js bower install svgsaver ```

JSPM

```js 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