exupero / saveSvgAsPng

Save SVGs as PNGs from the browser.
MIT License
1.09k stars 362 forks source link

TypeError #215

Closed falali009 closed 5 years ago

falali009 commented 5 years ago

saveSvgAsPng.js:232 Uncaught (in promise) TypeError: Cannot destructure property width of 'undefined' or 'null'.

from

https://github.com/chanind/hanzi-writer

i want download this demo`s target svg

saveSvgAsPng(document.getElementById("target"), "diagram.png");
exupero commented 5 years ago

What does document.getElementById("target") return? It sounds like its tagName is not "svg" and it has no "getBBox" method.

falali009 commented 5 years ago

this target is must be svg ‘s id ?

exupero commented 5 years ago

It must be the ID of either the SVG node or one of its children. If you're trying to export HTML, take a look at canvg and see if it will do what you want.

falali009 commented 5 years ago

thank you ! ORZ~~