SvgReaderSettings Class

Contains the settings used to read an SVG file with SvgReader.

Namespace: Aurigma.GraphicsMill.Codecs
Assembly: Aurigma.GraphicsMill (in Aurigma.GraphicsMill.dll)

Syntax

C#
public sealed class SvgReaderSettings

Remarks

Pass an instance of this class to the SvgReader(String, SvgReaderSettings) or SvgReader(Stream, SvgReaderSettings) constructor. The reader copies the settings, so you can reuse one instance for several readers.

Examples

C#
const string assetsPrefix = "assets/";
const string assetsFolder = @"Images";

var settings = new SvgReaderSettings();

// The SVG file refers to images in the "assets" folder, which is stored somewhere else.
settings.ResolveImage = args =>
{
    if (args.Href.StartsWith(assetsPrefix, StringComparison.OrdinalIgnoreCase))
    {
        var fileName = System.IO.Path.Combine(assetsFolder, args.Href.Substring(assetsPrefix.Length));

        // The reader takes the image when the property is set, so you can dispose the bitmap right away.
        using (var bitmap = new Bitmap(fileName))
        {
            args.Image = bitmap;
        }
    }

    // If you set neither Image nor GraphicsContainer, the image is loaded from the folder of the SVG file.
};

using (var reader = new SvgReader(@"Images\SvgWithImage.svg", settings))
using (var writer = ImageWriter.Create(@"Images\Output\SvgWithImage.png"))
{
    Pipeline.Run(reader + writer);
}

Inheritance Hierarchy

System.Object
L Aurigma.GraphicsMill.Codecs.SvgReaderSettings

See Also

Reference