Search Results for

    Show / Hide Table of Contents

    Class SvgDocument

    The class used to create and load SVG documents.

    Inheritance
    Object
    SvgElement
    SvgFragment
    SvgDocument
    Implements
    ISvgTransformable
    ICloneable
    ISvgNode
    ISvgViewPort
    ISvgBoundable
    System.ComponentModel.ITypeDescriptorContext
    IServiceProvider
    Inherited Members
    SvgFragment.Namespace
    SvgFragment.Width
    SvgFragment.Height
    SvgFragment.ViewBox
    SvgFragment.AspectRatio
    SvgFragment.FontSize
    SvgFragment.FontFamily
    SvgFragment.SpaceHandling
    SvgFragment.DeepCopy()
    SvgFragment.DeepCopy<T>()
    SvgFragment.ISvgBoundable.Location
    SvgFragment.ISvgBoundable.Size
    SvgFragment.ISvgBoundable.Bounds
    SvgFragment.PushTransforms(ISvgRenderer)
    SvgFragment.Render(ISvgRenderer)
    SvgFragment.Path
    SvgFragment.Bounds
    SvgFragment.GetDimensions()
    SvgElement.AddStyle(String, String, Int32)
    SvgElement.FlushStyles(Boolean)
    SvgElement.ContainsAttribute(String)
    SvgElement.TryGetAttribute(String, String)
    SvgElement.HttpClient
    SvgElement.Namespaces
    SvgElement.ElementNamespace
    SvgElement.ElementName
    SvgElement.Color
    SvgElement.Content
    SvgElement.Events
    SvgElement.Load
    SvgElement.Children
    SvgElement.Nodes
    SvgElement.Descendants()
    SvgElement.HasChildren()
    SvgElement.Parent
    SvgElement.Parents
    SvgElement.ParentsAndSelf
    SvgElement.OwnerDocument
    SvgElement.Attributes
    SvgElement.Writing
    SvgElement.GetAttribute<TAttributeType>(String, Boolean, TAttributeType)
    SvgElement.CustomAttributes
    SvgElement.Transforms
    SvgElement.ID
    SvgElement.SetAndForceUniqueID(String, Boolean, Action<SvgElement, String, String>)
    SvgElement.AddElement(SvgElement, Int32)
    SvgElement.ChildAdded
    SvgElement.RemoveElement(SvgElement)
    SvgElement.InitialiseFromXML(XmlReader, SvgDocument)
    SvgElement.ShouldWriteElement()
    SvgElement.WriteStartElement(XmlWriter)
    SvgElement.WriteEndElement(XmlWriter)
    SvgElement.AutoPublishEvents
    SvgElement.WriteChildren(XmlWriter)
    SvgElement.Clone()
    SvgElement.ISvgNode.DeepCopy()
    SvgElement.AttributeChanged
    SvgElement.OnAttributeChanged(AttributeEventArgs)
    SvgElement.ContentChanged
    SvgElement.OnContentChanged(ContentEventArgs)
    SvgElement.RegisterEvents(ISvgEventCaller)
    SvgElement.UnregisterEvents(ISvgEventCaller)
    SvgElement.Click
    SvgElement.MouseDown
    SvgElement.MouseUp
    SvgElement.MouseMove
    SvgElement.MouseScroll
    SvgElement.MouseOver
    SvgElement.MouseOut
    SvgElement.CreateMouseEventAction(Action<Object, MouseArg>)
    SvgElement.RaiseMouseClick(Object, MouseArg)
    SvgElement.RaiseMouseDown(Object, MouseArg)
    SvgElement.RaiseMouseUp(Object, MouseArg)
    SvgElement.RaiseMouseMove(Object, MouseArg)
    SvgElement.RaiseMouseOver(Object, MouseArg)
    SvgElement.RaiseMouseOut(Object, MouseArg)
    SvgElement.OnMouseScroll(Int32, Boolean, Boolean, Boolean, String)
    SvgElement.RaiseMouseScroll(Object, MouseScrollArg)
    SvgElement.PopTransforms(ISvgRenderer)
    SvgElement.ISvgTransformable.PushTransforms(ISvgRenderer)
    SvgElement.ISvgTransformable.PopTransforms(ISvgRenderer)
    SvgElement.TransformedBounds(RectangleF)
    SvgElement.RenderElement(ISvgRenderer)
    SvgElement.RenderChildren(ISvgRenderer)
    SvgElement.AddPaths(SvgElement, GraphicsPath)
    SvgElement.GetPaths(SvgElement, ISvgRenderer)
    SvgElement.IsPathDirty
    SvgElement.InvalidateChildPaths()
    SvgElement.FixOpacityValue(Single)
    SvgElement.Fill
    SvgElement.Stroke
    SvgElement.FillRule
    SvgElement.FillOpacity
    SvgElement.StrokeWidth
    SvgElement.StrokeLineCap
    SvgElement.StrokeLineJoin
    SvgElement.StrokeMiterLimit
    SvgElement.StrokeDashArray
    SvgElement.StrokeDashOffset
    SvgElement.StrokeOpacity
    SvgElement.Opacity
    SvgElement.ShapeRendering
    SvgElement.ColorInterpolation
    SvgElement.ColorInterpolationFilters
    SvgElement.Visibility
    SvgElement.Display
    SvgElement.TextAnchor
    SvgElement.BaselineShift
    SvgElement.FontStyle
    SvgElement.FontVariant
    SvgElement.TextDecoration
    SvgElement.FontWeight
    SvgElement.FontStretch
    SvgElement.TextTransformation
    SvgElement.Font
    SvgElement.ValidateFontFamily(String, SvgDocument, SvgFontManager)
    Object.Equals(Object)
    Object.Equals(Object, Object)
    Object.GetHashCode()
    Object.GetType()
    System.Object.MemberwiseClone()
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.ToString()
    Namespace: Svg
    Assembly: Svg.dll
    Syntax
    public class SvgDocument : SvgFragment, ISvgTransformable, ICloneable, ISvgNode, ISvgViewPort, ISvgBoundable, ITypeDescriptorContext, IServiceProvider

    Constructors

    | Improve this Doc View Source

    SvgDocument()

    Initializes a new instance of the SvgDocument class.

    Declaration
    public SvgDocument()

    Properties

    | Improve this Doc View Source

    BaseUri

    Declaration
    public Uri BaseUri { get; set; }
    Property Value
    Type Description
    Uri
    | Improve this Doc View Source

    DisableDtdProcessing

    Skip the Dtd Processing for faster loading of svgs that have a DTD specified. For Example Adobe Illustrator svgs.

    Declaration
    public static bool DisableDtdProcessing { get; set; }
    Property Value
    Type Description
    Boolean
    | Improve this Doc View Source

    ExternalCSSHref

    Gets or sets an external Cascading Style Sheet (CSS)

    Declaration
    public string ExternalCSSHref { get; set; }
    Property Value
    Type Description
    System.String
    | Improve this Doc View Source

    IdManager

    Gets an SvgElementIdManager for this document.

    Declaration
    protected virtual SvgElementIdManager IdManager { get; }
    Property Value
    Type Description
    SvgElementIdManager
    | Improve this Doc View Source

    Overflow

    Declaration
    public override SvgOverflow Overflow { get; }
    Property Value
    Type Description
    SvgOverflow
    Overrides
    SvgFragment.Overflow
    | Improve this Doc View Source

    PointsPerInch

    Declaration
    public static int PointsPerInch { get; set; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    Ppi

    Gets or sets the Pixels Per Inch of the rendered image.

    Declaration
    public int Ppi { get; set; }
    Property Value
    Type Description
    Int32
    | Improve this Doc View Source

    ResolveExternalElements

    Which types of external elements, for example text definitions, are allowed to be resolved. Defaults to Local and Remote.

    Declaration
    public static ExternalType ResolveExternalElements { get; set; }
    Property Value
    Type Description
    ExternalType
    | Improve this Doc View Source

    ResolveExternalImages

    Which types of external images are allowed to be resolved. Defaults to Local and Remote.

    Declaration
    public static ExternalType ResolveExternalImages { get; set; }
    Property Value
    Type Description
    ExternalType
    | Improve this Doc View Source

    ResolveExternalXmlEntites

    Which types of XML external entities are allowed to be resolved. Defaults to None to prevent XXE.

    Declaration
    public static ExternalType ResolveExternalXmlEntites { get; set; }
    Property Value
    Type Description
    ExternalType
    | Improve this Doc View Source

    SkipGdiPlusCapabilityCheck

    Skip check whether the GDI+ can be loaded.

    Declaration
    public static bool SkipGdiPlusCapabilityCheck { get; set; }
    Property Value
    Type Description
    Boolean
    Remarks

    Set to true on systems that do not support GDI+ like UWP.

    | Improve this Doc View Source

    X

    Declaration
    public override SvgUnit X { get; }
    Property Value
    Type Description
    SvgUnit
    Overrides
    SvgFragment.X
    | Improve this Doc View Source

    Y

    Declaration
    public override SvgUnit Y { get; }
    Property Value
    Type Description
    SvgUnit
    Overrides
    SvgFragment.Y

    Methods

    | Improve this Doc View Source

    Draw()

    Renders the SvgDocument and returns the image as a .

    Declaration
    public virtual Bitmap Draw()
    Returns
    Type Description
    Bitmap

    A containing the rendered document.

    | Improve this Doc View Source

    Draw(Bitmap)

    Renders the SvgDocument into a given Bitmap .

    Declaration
    public virtual void Draw(Bitmap bitmap)
    Parameters
    Type Name Description
    Bitmap bitmap
    | Improve this Doc View Source

    Draw(Graphics)

    Renders the SvgDocument to the specified .

    Declaration
    public void Draw(Graphics graphics)
    Parameters
    Type Name Description
    Graphics graphics

    The to be rendered to.

    Exceptions
    Type Condition
    ArgumentNullException

    The graphics parameter cannot be null.

    | Improve this Doc View Source

    Draw(Graphics, Nullable<SizeF>)

    Renders the SvgDocument to the specified .

    Declaration
    public void Draw(Graphics graphics, SizeF? size)
    Parameters
    Type Name Description
    Graphics graphics

    The to be rendered to.

    System.Nullable<SizeF> size

    The SizeF to render the document. If null document is rendered at the default document size.

    Exceptions
    Type Condition
    ArgumentNullException

    The graphics parameter cannot be null.

    | Improve this Doc View Source

    Draw(ISvgRenderer)

    Renders the SvgDocument to the specified ISvgRenderer.

    Declaration
    public void Draw(ISvgRenderer renderer)
    Parameters
    Type Name Description
    ISvgRenderer renderer

    The ISvgRenderer to render the document with.

    Exceptions
    Type Condition
    ArgumentNullException

    The renderer parameter cannot be null.

    | Improve this Doc View Source

    Draw(Int32, Int32)

    Renders the SvgDocument in given size and returns the image as a . If one of rasterWidth and rasterHeight is zero, the image is scaled preserving aspect ratio, otherwise the aspect ratio is ignored.

    Declaration
    public virtual Bitmap Draw(int rasterWidth, int rasterHeight)
    Parameters
    Type Name Description
    Int32 rasterWidth
    Int32 rasterHeight
    Returns
    Type Description
    Bitmap

    A containing the rendered document.

    | Improve this Doc View Source

    EnsureSystemIsGdiPlusCapable()

    Ensure that the running system is GDI capable, if not this will yield a SvgGdiPlusCannotBeLoadedException exception.

    Declaration
    public static void EnsureSystemIsGdiPlusCapable()
    | Improve this Doc View Source

    FromSvg<T>(String)

    Attempts to create an SVG document from the specified string data.

    Declaration
    public static T FromSvg<T>(string svg)
        where T : SvgDocument, new()
    Parameters
    Type Name Description
    System.String svg

    The SVG data.

    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    GetElementById(String)

    Retrieves the SvgElement with the specified ID.

    Declaration
    public virtual SvgElement GetElementById(string id)
    Parameters
    Type Name Description
    System.String id

    A System.String containing the ID of the element to find.

    Returns
    Type Description
    SvgElement

    An SvgElement of one exists with the specified ID; otherwise false.

    | Improve this Doc View Source

    GetElementById<TSvgElement>(String)

    Retrieves the SvgElement with the specified ID.

    Declaration
    public virtual TSvgElement GetElementById<TSvgElement>(string id)
        where TSvgElement : SvgElement
    Parameters
    Type Name Description
    System.String id

    A System.String containing the ID of the element to find.

    Returns
    Type Description
    TSvgElement

    An SvgElement of one exists with the specified ID; otherwise false.

    Type Parameters
    Name Description
    TSvgElement
    | Improve this Doc View Source

    Open(String)

    Opens the document at the specified path and loads the SVG contents.

    Declaration
    public static SvgDocument Open(string path)
    Parameters
    Type Name Description
    System.String path

    A System.String containing the path of the file to open.

    Returns
    Type Description
    SvgDocument

    An SvgDocument with the contents loaded.

    Exceptions
    Type Condition
    FileNotFoundException

    The document at the specified path cannot be found.

    | Improve this Doc View Source

    Open(XmlDocument)

    Opens an SVG document from the specified XmlDocument.

    Declaration
    public static SvgDocument Open(XmlDocument document)
    Parameters
    Type Name Description
    XmlDocument document

    The XmlDocument containing the SVG document XML.

    Returns
    Type Description
    SvgDocument
    Exceptions
    Type Condition
    ArgumentNullException

    The document parameter cannot be null.

    | Improve this Doc View Source

    Open<T>(Stream)

    Attempts to open an SVG document from the specified Stream.

    Declaration
    public static T Open<T>(Stream stream)
        where T : SvgDocument, new()
    Parameters
    Type Name Description
    Stream stream

    The Stream containing the SVG document to open.

    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    Open<T>(Stream, SvgOptions)

    Opens an SVG document from the specified Stream and adds the specified entities.

    Declaration
    public static T Open<T>(Stream stream, SvgOptions svgOptions)
        where T : SvgDocument, new()
    Parameters
    Type Name Description
    Stream stream

    The Stream containing the SVG document to open.

    SvgOptions svgOptions

    Css Style that will be applied to the Svg Document

    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    ArgumentNullException

    The stream parameter cannot be null.

    | Improve this Doc View Source

    Open<T>(Stream, Dictionary<String, String>)

    Opens an SVG document from the specified Stream and adds the specified entities.

    Declaration
    [Obsolete("Use Open<T>(Stream stream, SvgOptions svgOptions)")]
    public static T Open<T>(Stream stream, Dictionary<string, string> entities)
        where T : SvgDocument, new()
    Parameters
    Type Name Description
    Stream stream

    The Stream containing the SVG document to open.

    Dictionary<System.String, System.String> entities

    Custom entity definitions.

    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    ArgumentNullException

    The stream parameter cannot be null.

    | Improve this Doc View Source

    Open<T>(String)

    Opens the document at the specified path and loads the SVG contents.

    Declaration
    public static T Open<T>(string path)
        where T : SvgDocument, new()
    Parameters
    Type Name Description
    System.String path

    A System.String containing the path of the file to open.

    Returns
    Type Description
    T

    An SvgDocument with the contents loaded.

    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    FileNotFoundException

    The document at the specified path cannot be found.

    | Improve this Doc View Source

    Open<T>(String, SvgOptions)

    Opens the document at the specified path and loads the SVG contents.

    Declaration
    public static T Open<T>(string path, SvgOptions svgOptions)
        where T : SvgDocument, new()
    Parameters
    Type Name Description
    System.String path

    A System.String containing the path of the file to open.

    SvgOptions svgOptions

    A dictionary of custom entity definitions to be used when resolving XML entities within the document.

    Returns
    Type Description
    T

    A SvgDocument with the contents loaded.

    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    FileNotFoundException

    The document at the specified path cannot be found.

    | Improve this Doc View Source

    Open<T>(String, Dictionary<String, String>)

    Opens the document at the specified path and loads the SVG contents.

    Declaration
    [Obsolete("Use Open<T>(string path, SvgOptions svgOptions)")]
    public static T Open<T>(string path, Dictionary<string, string> entities)
        where T : SvgDocument, new()
    Parameters
    Type Name Description
    System.String path

    A System.String containing the path of the file to open.

    Dictionary<System.String, System.String> entities

    A dictionary of custom entity definitions to be used when resolving XML entities within the document.

    Returns
    Type Description
    T

    An SvgDocument with the contents loaded.

    Type Parameters
    Name Description
    T
    Exceptions
    Type Condition
    FileNotFoundException

    The document at the specified path cannot be found.

    | Improve this Doc View Source

    Open<T>(XmlReader)

    Attempts to open an SVG document from the specified System.Xml.XmlReader.

    Declaration
    public static T Open<T>(XmlReader reader)
        where T : SvgDocument, new()
    Parameters
    Type Name Description
    System.Xml.XmlReader reader

    The System.Xml.XmlReader containing the SVG document to open.

    Returns
    Type Description
    T
    Type Parameters
    Name Description
    T
    | Improve this Doc View Source

    OpenAsBitmap(String)

    Declaration
    public static Bitmap OpenAsBitmap(string path)
    Parameters
    Type Name Description
    System.String path
    Returns
    Type Description
    Bitmap
    | Improve this Doc View Source

    OpenAsBitmap(XmlDocument)

    Declaration
    public static Bitmap OpenAsBitmap(XmlDocument document)
    Parameters
    Type Name Description
    XmlDocument document
    Returns
    Type Description
    Bitmap
    | Improve this Doc View Source

    OverwriteIdManager(SvgElementIdManager)

    Overwrites the current IdManager with a custom implementation. Be careful with this: If elements have been inserted into the document before, you have to take care that the new IdManager also knows of them.

    Declaration
    public void OverwriteIdManager(SvgElementIdManager manager)
    Parameters
    Type Name Description
    SvgElementIdManager manager
    | Improve this Doc View Source

    RasterizeDimensions(ref SizeF, Int32, Int32)

    If both or one of raster height and width is not given (0), calculate that missing value from original SVG size while keeping original SVG size ratio

    Declaration
    public virtual void RasterizeDimensions(ref SizeF size, int rasterWidth, int rasterHeight)
    Parameters
    Type Name Description
    SizeF size
    Int32 rasterWidth
    Int32 rasterHeight
    | Improve this Doc View Source

    SystemIsGdiPlusCapable()

    Validate whether the system has GDI+ capabilities (non Windows related).

    Declaration
    public static bool SystemIsGdiPlusCapable()
    Returns
    Type Description
    Boolean

    Boolean whether the system is capable of using GDI+

    | Improve this Doc View Source

    Write(Stream, Boolean)

    Declaration
    public void Write(Stream stream, bool useBom = true)
    Parameters
    Type Name Description
    Stream stream
    Boolean useBom
    | Improve this Doc View Source

    Write(String, Boolean)

    Declaration
    public void Write(string path, bool useBom = true)
    Parameters
    Type Name Description
    System.String path
    Boolean useBom
    | Improve this Doc View Source

    Write(XmlWriter)

    Declaration
    public override void Write(XmlWriter writer)
    Parameters
    Type Name Description
    System.Xml.XmlWriter writer
    Overrides
    SvgElement.Write(XmlWriter)
    | Improve this Doc View Source

    WriteAttributes(XmlWriter)

    Declaration
    protected override void WriteAttributes(XmlWriter writer)
    Parameters
    Type Name Description
    System.Xml.XmlWriter writer
    Overrides
    SvgElement.WriteAttributes(XmlWriter)

    Explicit Interface Implementations

    | Improve this Doc View Source

    ITypeDescriptorContext.Container

    Declaration
    IContainer ITypeDescriptorContext.Container { get; }
    Returns
    Type Description
    IContainer
    | Improve this Doc View Source

    ITypeDescriptorContext.Instance

    Declaration
    object ITypeDescriptorContext.Instance { get; }
    Returns
    Type Description
    Object
    | Improve this Doc View Source

    ITypeDescriptorContext.OnComponentChanged()

    Declaration
    void ITypeDescriptorContext.OnComponentChanged()
    | Improve this Doc View Source

    ITypeDescriptorContext.OnComponentChanging()

    Declaration
    bool ITypeDescriptorContext.OnComponentChanging()
    Returns
    Type Description
    Boolean
    | Improve this Doc View Source

    ITypeDescriptorContext.PropertyDescriptor

    Declaration
    PropertyDescriptor ITypeDescriptorContext.PropertyDescriptor { get; }
    Returns
    Type Description
    System.ComponentModel.PropertyDescriptor
    | Improve this Doc View Source

    IServiceProvider.GetService(Type)

    Declaration
    object IServiceProvider.GetService(Type serviceType)
    Parameters
    Type Name Description
    Type serviceType
    Returns
    Type Description
    Object

    Implements

    ISvgTransformable
    System.ICloneable
    ISvgNode
    ISvgViewPort
    ISvgBoundable
    System.ComponentModel.ITypeDescriptorContext
    System.IServiceProvider

    Extension Methods

    SvgExtentions.GetXML(SvgDocument)
    SvgExtentions.GetXML(SvgElement)
    SvgExtentions.HasNonEmptyCustomAttribute(SvgElement, String)
    SvgExtentions.ApplyRecursive(SvgElement, Action<SvgElement>)
    SvgExtentions.ApplyRecursiveDepthFirst(SvgElement, Action<SvgElement>)
    • Improve this Doc
    • View Source
    In This Article
    Back to top Generated by DocFX