Click or drag to resize
AB4D logo

ReaderSvgRead Method

Reads svg or svgz file from file, from online source or from stream. The file is read as Shapes (Canvas, Path, Ellipse, etc.).
Overload List
  NameDescription
Public methodCode exampleRead(Stream)
Reads svg file from stream - useful for reading svg files from resources. The file is read as Shapes (Canvas, Path, Ellipse, etc.).
Public methodCode exampleRead(String)
Reads svg or svgz file from file system or from online source. The file is read as Shapes (Canvas, Path, Ellipse, etc.).
Top
Examples

The following sample loads the mySample.svg file and adds it to the myStackPanel.

Viewbox sampleViewbox = Ab2d.ReaderSvg.Instance.Read(@"c:\mySample.svg");
myStackPanel.Children.Add(sampleViewbox);

The following sample loads the mySample.svg file from web site.

Ab2d.ReaderSvg myReaderSvg = new Ab2d.ReaderSvg();

Viewbox sampleViewbox = myReaderSvg.Read(@"http://www.myWeb.com/test/mySample.svg");
myStackPanel.Children.Add(sampleViewbox);
The following sample shows how to read svg file from Application's Resource (mySample.svg file is included into the project under cliparts folder and its build action is set to Resource):
Uri uri = new Uri("/cliparts/mySample.svg", UriKind.Relative);
using (Stream svgStream = Application.GetResourceStream(uri).Stream)
{
    clipartFromResource = Ab2d.ReaderSvg.Instance.Read(svgStream);
}

myStackPanel.Children.Add(clipartFromResource);
See Also