1.0.2 • Published 4 years ago

svg2dataurl v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

svg2dataurl

Convert SVG to SVG/PNG/JPEG DataURL. Just forked from likr/svg-dataurl and then do some modifications. 1. Instead of commonsjs module ,use es6 module. 2. Fix some issues.

Install

$ npm install svg2dataurl

Usage

import {SvgConverter} from 'svg2dataurl'

const svg = documentGetElementById('chart')
const downloadLink = documentGetElementById('#download-link')
SvgConverter.loadFromElement(svg).then((converter) => {
  const dataUrl = converter.pngDataURL()
  downloadLink.setAttribute('href', dataUrl)
})