Search code examples
svgjvectormap

removing svg transparent bakcground


I use jvectormap. I create map. I need to save this svg map as image. I use a plugin named saveSvgAsPng.js. It works ok. My problem is that ,png image makes transparent. Is there a method that I remove svg background transparency? Thanks in advance.


Solution

  • Have you tried looking at the usage Docs for saveSvgAsPng ?

    https://github.com/exupero/saveSvgAsPng

    saveSvgAsPng(document.getElementById("diagram"), "diagram.png", {backgroundColor: "white"});
    

    Try and pass "white" or the HEX color value "#FFFFFF"

    Pass backgroundColor in the options object:

    Available Options:

    • backgroundColor — Creates a PNG with the given background color. Defaults to transparent.
    • scale — Changes the resolution of the output PNG. Defaults to 1, the same dimensions as the source SVG.
    • selectorRemap — A function that takes a CSS selector and produces its replacement in the CSS that's inlined into the SVG. Useful if your SVG style selectors are scoped by ancestor elements in your HTML document.