How to export svg as a image in Gojs

I am using diagram.MakeSvg () it will create the inline svg image but i need to save like in file.svg, without converting the base64 in the Client side because while converting the inline svg to base64 it taking much time.is there any solution in gojs directly export as svg image,If you don’t mind can you share me link on gojs related on this.Thanks Advance.

Also, read How to save SVG diagram? - #2 by simon

I triyed the XMLSerializer , if i passing XmlSerializer return value in another string its showing compiler error.
var img = this.myDiagram.makeSvg({
scale: 1,
// type: “image/png”,
background: “white”,
// position: new go.Point(p.x + j, p.y + i),
maxSize: new go.Size(width, height)
});
var xml = new XMLSerializer().serializeToString(img);
console.log(xml);

I just tried this, and it worked well in three different browsers:

<button onclick="alert(new XMLSerializer().serializeToString(myDiagram.makeSvg()))">SVG</button>

Thank you so much Walter Its Working…

Richard, if you need, I also succeeded in directly downloading the SVG file by using this workaround:

var svg = myDiagram.makeSvg();
var form1 = document.createElement("div");
form1.setAttribute("id", "live_svg");
form1.setAttribute("style", "visibility: hidden");
form1.appendChild(svg);
document.body.appendChild(form1);
document.getElementById("idsvg").value=form1.innerHTML;

var form = document.getElementById("myform");
form.submit();

Hi bartoli.
Thanks for you help ,could you tell me ,may i know what is behind submit(), how does a form directly convert svg to pdf?

Actually it does not convert SVG to PDF, but directly downloads the svg file to disk using a temporary form.

This is the code in the HTML page:

function exportDiagram()
{
    var svg = myDiagram.makeSvg(style);
    var form1 = document.createElement("div");
    form1.setAttribute("id", "live_svg");
    form1.appendChild(svg);
    document.body.appendChild(form1);
document.getElementById("idsvg").value=form1.innerHTML;
}

<body>
<form name="myform" method="post" action="savesvg.php">		
    <input id="idsvg" type="text" name="svg"/>
</form>
</body>

And this is the savesvg.php file:

<?php
$file = $_POST['file'];
$data = $_POST['svg'];
header('Content-type: image/svg+xml');
header("Content-Disposition: attachment; filename=$file");
echo('<?xml version="1.0" encoding="iso-8859-1"?>' . "\n"); 
echo('<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 20000303 Stylable//EN" "http://www.w3.org/TR/2000/03/WD-SVG-20000303/DTD/svg-20000303-stylable.dtd">' . "\n"); 
echo $data;
?>

If you want to convert SVG to PDF, I think you need an external program…