How to create an image from svg

can we create an image from svg? The below is my code snippet. Please help me to create an image of force connected graph.

var svg = $(“#container0”).html();
var imgsrc = “data:image/svg+xml;base64,” + btoa(svg);