How to save SVG diagram?

Hi,
I’m trying to export my diagram to SVG format after clicking on a button.

Following your example, I execute the following code in the onclick button callback:

var newWindow = window.open("","newWindow");
if (!newWindow)
{
    window.alert("Unable to export diagram!");
    return;
}
var newDocument = newWindow.document;
var style = {
    document: newDocument,
    background: "white",
    scale: 1
};
var svg = myDiagram.makeSvg(style);
newDocument.body.appendChild(svg);

Everything goes fine, the diagram is correctly converted into SVG in a new browser tab, but I’m unable to save it. “Save as…” for the whole page is not enabled; after right-click on the graph, “Save image as…” is not present; the only thing I can do on the graphics is to select some parts with the mouse like a text editor, but even opening the Inspect tool, just shows the <svg> tag, but I’m still unable to save it.

Do you know how to directly download the raw SVG file to disk?

Many thanks,
Guido

This is somewhat outside the scope of GoJS, and it might be different for every browser.

You might have to experiment. Searching yields examples like this, where a person encodes their SVG and then sets it as an <img> source, and lets the user download the .svg. There are probably more complete examples out there.

Ok, I will take a look at it, thanks anyway!

PS: I noticed that also in the GoJS Intro page on SVG, I’m unable to save the generated graphics from the sample. I’m with Google Chrome 55 on Ubuntu Linux 16.04.