HTML frontend SVG export download with JavaScript -


i'm using highcharts create svg charts. so, chart shown in frontend, svghtml tag.

now want export chart svg file.


my effort

since svg generated purely in frontend, backend knows nothing it. , if want initialize download content, know make http response content.

so can grab svg content string, upload http request, response content was.


i want better

i think there logically no need transfer such way, because frontend knows want.

i turned help: possible initialize download in frontend?

you can generate download links directly using base64 encoded version of svg data.

you need add data:application/octet-stream;base64, in front of base64 encoded data.

here simple fiddle demonstrate;

http://jsfiddle.net/xkbhf7mo/

edit: can specify filename download attribute in anchor tag make things more pretty.

<a download="your_file_name" href='...'>download</a>


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -