This sample shows how to setup an elementFinished option for Diagram.makeSvg that will replace the SVG <image> tag's href with a Base64 URI instead of pointing to the Picture.source. This can be useful to reduce external dependencies within your exported SVG.

This method will only work if you assets are at the same origin, or otherwise not blocked by a cross-origin request policy.


GoJS Features in this sample

Exporting SVGs

GoJS has one function for creating SVG: Diagram.makeSVG, which returns a new SVGElement with a representation of a GoJS Diagram. The method has a single argument, a JavaScript Object that contains several definable properties, enumerated in the documentation. More information can be found in the GoJS Intro.

Related samples


Exporting Raster Images

GoJS has two functions for creating raster images: Diagram.makeImageData, which outputs a Base64 image data string, and Diagram.makeImage, which is a convenience function that calls Diagram.makeImageData and returns a new HTMLImageElement with the image data as its source. Both functions have the same single argument, a JavaScript Object that contains several definable properties, enumerated in the documentation. More information can be found in the GoJS Intro.

Related samples