SvgDocument Class

Represents an SVG document. Provides methods for loading, editing and saving SVG files.

Definition

Namespace: DotMake.SvgSprite
Assembly: DotMake.SvgSprite (in DotMake.SvgSprite.dll) Version: 1.0.0
C#
public class SvgDocument
Inheritance
Object    SvgDocument

Example

C#
SvgDocument svgDocument;

//Create an empty SVG document
svgDocument = new SvgDocument();

//Load an SVG document from a file
svgDocument = new SvgDocument("SomeFile.svg");

//Load an SVG document from a stream
svgDocument = new SvgDocument(stream);

//Load an SVG document from a text reader
svgDocument = new SvgDocument(textReader);

//Load an SVG document from a xml reader
svgDocument = new SvgDocument(xmlReader);

//Load an SVG document from a string
svgDocument = SvgDocument.Parse(svgString);
C#
//Saves this SVG to a file
svgDocument.Save("SomeFile.svg");
//Save minified
svgDocument.Save("SomeFile.svg", true);

//Saves this SVG to a stream
svgDocument.Save(stream);
//Save minified
svgDocument.Save(stream, true);

//Saves this SVG to a text writer
svgDocument.Save(textWriter);
//Save minified
svgDocument.Save(textWriter, true);

//Saves this SVG to a xml writer
svgDocument.Save(xmlWriter);
//Save minified
svgDocument.Save(xmlWriter, true);

//Saves this SVG to a string
svgString = svgDocument.ToString();
//Save minified
svgString = svgDocument.ToString(true);

Constructors

SvgDocument Initializes a new instance of the SvgDocument class.
SvgDocument(Stream) Initializes a new instance of the SvgDocument class from a stream.
SvgDocument(String) Initializes a new instance of the SvgDocument class from a file.
SvgDocument(TextReader) Initializes a new instance of the SvgDocument class from a text reader.
SvgDocument(XmlReader) Initializes a new instance of the SvgDocument class from a xml reader.

Properties

Root Gets the root element of this SVG document, i.e. the <svg> tag.

Methods

Parse Creates a new instance of the SvgDocument class from a string.
Save(Stream, Boolean) Saves this SVG to a stream.
Save(String, Boolean) Saves this SVG to a file.
Save(TextWriter, Boolean) Saves this SVG to a text writer.
Save(XmlWriter, Boolean) Saves this SVG to a xml writer.
ToStringReturns the indented XML for this SVG.
(Overrides ObjectToString)
ToString(Boolean)Returns the XML for this SVG, optionally disabling formatting.

Fields

Namespace Gets the namespace for SVG documents, i.e. http://www.w3.org/2000/svg.

See Also