Skip to content

hasankzl/htmlsvg

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 

Repository files navigation

htmlsvg

converts html element to svg element (rect,text,img).

online demo:

https://htmlsvg.netlify.app/

Install

$ npm install htmlsvg

Usage

import htmlToSvg from "htmlsvg";
const htmlElement = document.getElementById("DivId");
const svg = await htmlToSvg(htmlElement);
console.log(svg);

You can directly download svg with passing config object

import htmlToSvg from "htmlsvg";

const svgConfig = {
  downloadSvg: true,
  filename: "htmltosvg",
};
const htmlElement = document.getElementById("DivId");
const svg = await htmlToSvg(htmlElement, svgConfig);
console.log(svg);

You can directly download png with passing config object

import htmlToSvg from "htmlsvg";

const svgConfig = {
  downloadSvg: true,
  downloadPng: true,
  convertDataUrl: true, // you need to convert images to dataurl if you wanna download png image
  filename: "htmltosvg",
};
const htmlElement = document.getElementById("DivId");
const svg = await htmlToSvg(htmlElement, svgConfig);
console.log(svg);

About

javascript code converts html to svg

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published