john-bell-gw / svg-crowbar

Extracts an SVG node and accompanying styles from an HTML document and allows you to download it all as an SVG or a PNG file.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SVG Crowbar Library

NPM version code style: prettier Build Status

A standalone 3.5Kb JS client library based on Chrome bookmarklet.

The library provides functionality to trigger a download of a given SVG file having alle the styles inlined, to make it look the same when opened independently from the original HTML page.

It is also possible to use this library to convert an SVG to a PNG before downloading.

Usage

import downloadSvg from 'svg-crowbar';

downloadSvg(document.querySelector('svg'), 'my_svg');

or

import { downloadPng } from 'svg-crowbar';

downloadPng(document.querySelector('svg'));

Filename is determined by element id, class or page title, when not provided explicitly.

An error is thrown in case no valid SVG element was provided.

About

Extracts an SVG node and accompanying styles from an HTML document and allows you to download it all as an SVG or a PNG file.

License:MIT License


Languages

Language:JavaScript 57.4%Language:HTML 42.3%Language:CSS 0.3%