javascript - How can I save my generated svg code to a .svg file in the client machine? -


i used snap.svg library generate, javascript, svg element in asp.net web form page loading other external .svg files , manipulating them in order final svg element. once composition of desired svg object finish , resulting svg element shows fine in page, need save .svg file in client machine, in user selected path. idea how directly? mean, whithout sending code server, generate file in server, , download file client machine.

you can in 2 simple steps:

  1. use new xmlserializer().serializetostring(svg); string svg
  2. use filesaver.js save file (https://github.com/koffsyrup/filesaver.js)

this should work in cases (except safari, of course).


Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -