This project is read-only.

Save SvgDocument back to Svg file

Feb 10, 2010 at 3:38 PM
Edited Feb 10, 2010 at 3:50 PM


This engine is very good. Very simple to use. I found all i need : Create, Onen, render, Edit, Combine, Transform svg. But i cant't find out how to Save edited SvgDocument to svg file. Maybe there are some way to get back edited XML ? Write didnt help me. MAybe because SvgDocument c# code contains

public void Write(Stream stream)        {        }

public void Write(string path)        {        }


I try SvgElement  WriteElement bot i got totally empty file.

Please help me.

Feb 11, 2010 at 5:02 AM

Hi Sparks,

I'm sorry to say that there is no support for Write at the moment (I added it in there hoping to get it implemented but never did...)

Looking at the code, it wouldn't take much to get it working if you wanted to have a go at it yourself?

WriteAttributes in SvgElement.cs appears to be the only method that hasn't been implemented. It could quite possibly just be a case of iterating though the Attributes dictionary and using TypeConverter to convert the types to System.String before writing them to the XmlTextWriter.

Hmmm, I see why WriteElement is currently returning nothing. The problem is that ElementName is null and this only gets set during a Load and it sounds like you might be using something like 'new SvgCircle()'?

I'll have a think about how to best solve this issue and get back to you.


Feb 11, 2010 at 9:18 AM

Hi Scriv,

thx for answering.

Ok, i make it work. It's writing to the svg file now but there are some problems...

Width and Height in SvgFragment is not attribues. its just class variables...

/// <summary>
/// Gets or sets the width of the fragment.
/// </summary>
/// <value>The width.</value>
public SvgUnit Width
get { return this._width; }
set { this._width = value; }

like in SvgCircle "cx" attribute

        /// <summary>
/// Gets or sets the center X co-ordinate.
/// </summary>
/// <value>The center X.</value>
public SvgUnit CenterX
get { return this.Attributes.GetAttribute<SvgUnit>("cx"); }
if (this.Attributes.GetAttribute<SvgUnit>("cx") != value)
this.Attributes["cx"] = value;
this.IsPathDirty = true;

Also i have found that svg document looses its xmlns and xlink attributes. Maybe other tags looses something too.
So i will try to fix it. When it will work, if you wish, I can send updated code to you.

This is a short report about what i found i what i'm doing.

May 27, 2010 at 4:24 PM

Hi Sparks.

Did you manage writing the SVG back to file? Is there a plan to include this in the SVG source code.?




May 30, 2010 at 11:55 PM


Better writing support was added to the source code recently (the issue Sparks has above is not an issue in the source drop). That support will be enhanced as time goes on.

I haven't recieved any code from Sparks unfortunately (I'd be more than happy to add his code to the project).


Jun 9, 2010 at 8:50 AM


Waiting Scirv Update....