[]
        
(Showing Draft Content)

GrapeCity.Documents.Svg.GcSvgDocument

Class GcSvgDocument

Namespace
GrapeCity.Documents.Svg
Assembly
GcDocs.Imaging.dll

Represents an SVG document.

public class GcSvgDocument : IDisposable
Inheritance
object
GcSvgDocument
Implements
System.IDisposable
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()

Constructors

GcSvgDocument()

Initializes an empty instance of the GcSvgDocument class.

public GcSvgDocument()

Properties

Cultures

Gets or sets the list of cultures to match values of the 'systemLanguage' attribute of SVG elements.

If this list is empty the language is taken from the current thread's CurrentCulture.

public List<CultureInfo> Cultures { get; set; }

Property Value

System.Collections.Generic.List<T><System.Globalization.CultureInfo>

CurrentColor

Gets or sets the currentColor value used by the SVG renderer.

public SvgColor? CurrentColor { get; set; }

Property Value

SvgColor?

CursiveFonts

Gets or sets the list of font names belonging to the Cursive font family.

public List<string> CursiveFonts { get; set; }

Property Value

System.Collections.Generic.List<T><string>

DefaultCursiveFonts

Gets the default list of font names belonging to the Cursive font family.

public static List<string> DefaultCursiveFonts { get; }

Property Value

System.Collections.Generic.List<T><string>

DefaultFantasyFonts

Gets the default list of font names belonging to the Fantasy font family.

public static List<string> DefaultFantasyFonts { get; }

Property Value

System.Collections.Generic.List<T><string>

DefaultMonospaceFonts

Gets the default list of font names belonging to the Serif font family.

public static List<string> DefaultMonospaceFonts { get; }

Property Value

System.Collections.Generic.List<T><string>

DefaultSansSerifFonts

Gets the default list of font names belonging to the SansSerif font family.

public static List<string> DefaultSansSerifFonts { get; }

Property Value

System.Collections.Generic.List<T><string>

DefaultSerifFonts

Gets the default list of font names belonging to the Serif font family.

public static List<string> DefaultSerifFonts { get; }

Property Value

System.Collections.Generic.List<T><string>

FantasyFonts

Gets or sets the list of font names belonging to the Fantasy font family.

public List<string> FantasyFonts { get; set; }

Property Value

System.Collections.Generic.List<T><string>

FontCollection

Gets or sets the custom font collection used for searching fonts and font fallbacks.

public FontCollection FontCollection { get; set; }

Property Value

FontCollection

FontFallbackScope

Gets or sets a value specifying the scope for searching fallback fonts for the glyphs missing in the mentioned type faces.

public FontFallbackScope FontFallbackScope { get; set; }

Property Value

FontFallbackScope

IsDisposed

Gets a value indicating whether the GcSvgDocument has been disposed of.

public bool IsDisposed { get; }

Property Value

bool

MonospaceFonts

Gets or sets the list of font names belonging to the Monospace font family.

public List<string> MonospaceFonts { get; set; }

Property Value

System.Collections.Generic.List<T><string>

RestrictedFontLookup

Gets or sets a value indicating whether the fonts should be searched in the custom collection only, if any specified, not in the system collection of fonts. The default is false.

public bool RestrictedFontLookup { get; set; }

Property Value

bool

RootSvg

Gets the root SVG element.

public SvgSvgElement RootSvg { get; }

Property Value

SvgSvgElement

SansSerifFonts

Gets or sets the list of font names belonging to the SansSerif font family.

public List<string> SansSerifFonts { get; set; }

Property Value

System.Collections.Generic.List<T><string>

SerifFonts

Gets or sets the list of font names belonging to the Serif font family.

public List<string> SerifFonts { get; set; }

Property Value

System.Collections.Generic.List<T><string>

Methods

ClearNamespacePrefixes()

Removes all namespace prefixes except "svg", "xlink", and "xml".

public void ClearNamespacePrefixes()

Dispose()

Releases unmanaged resources used by this object.

public void Dispose()

FromFile(string)

Creates a new GcSvgDocument from a specified SVG file.

public static GcSvgDocument FromFile(string path)

Parameters

path string

The SVG file path.

Returns

GcSvgDocument

The created SVG document.

FromStream(Stream, bool)

Creates a new GcSvgDocument from a specified SVG data stream, optionally leaving the stream open.

public static GcSvgDocument FromStream(Stream stream, bool leaveOpen)

Parameters

stream System.IO.Stream

The stream containing the SVG data.

leaveOpen bool

true to leave the stream open after reading the data, false to close the stream.

Returns

GcSvgDocument

The created SVG document.

FromStream(Stream)

Creates a new GcSvgDocument from a specified SVG data stream.

The stream will be closed after reading the SVG data. To keep the stream open, use the FromStream(Stream, bool) overload and pass true in the leaveOpen parameter.

public static GcSvgDocument FromStream(Stream stream)

Parameters

stream System.IO.Stream

The stream containing the SVG data.

Returns

GcSvgDocument

The created SVG document.

FromString(string)

Creates a new GcSvgDocument from a specified SVG string data.

public static GcSvgDocument FromString(string svgData)

Parameters

svgData string

The string containing the SVG data.

Returns

GcSvgDocument

An SVG document that was created.

FromSvgz(byte[])

Creates a new GcSvgDocument from binary data in SVGZ format.

public static GcSvgDocument FromSvgz(byte[] svgzData)

Parameters

svgzData byte[]

A byte array containing the SVG data packed with GZ format (see RFC 1952).

Returns

GcSvgDocument

An SVG document that was created.

GetElementByID(string)

Gets an SvgElement with the specified id, or null if nothing was found.

public SvgElement GetElementByID(string id)

Parameters

id string

Returns

SvgElement

GetElementsByClass(string)

Gets a list of SvgElements with the specified className.

public IReadOnlyList<SvgElement> GetElementsByClass(string className)

Parameters

className string

Returns

System.Collections.Generic.IReadOnlyList<T><SvgElement>

GetIntrinsicSize(SvgLengthUnits)

Calculates the intrinsic size of the SVG viewport, in specified units. The following units are supported:

public SizeF GetIntrinsicSize(SvgLengthUnits units)

Parameters

units SvgLengthUnits

Returns

System.Drawing.SizeF

The intrinsic size of SVG viewport, or System.Drawing.SizeF.Empty if the size is undefined.

GetNamespaceByPrefix(string)

Searches for a namespace with a specified prefix.

public string GetNamespaceByPrefix(string prefix)

Parameters

prefix string

The prefix to search for.

Returns

string

The namespace with the specified prefix, or null.

Exceptions

System.ArgumentNullException

GetNamespacePrefixes()

Returns an array with all registered namespace prefixes.

public string[] GetNamespacePrefixes()

Returns

string[]

GetPrefixByNamespace(string)

Searches for a prefix associated with a specified namespace.

public string GetPrefixByNamespace(string ns)

Parameters

ns string

The namespace to search for.

Returns

string

The prefix associated with the specified namespace, or null.

Exceptions

System.ArgumentNullException

Measure(PointF, float)

Calculates the content bounds of an SVG document when its viewport is drawn at a specified point.

public RectangleF Measure(PointF viewportPosition, float graphicsResolution = 96)

Parameters

viewportPosition System.Drawing.PointF

The coordinates for the top-left corner of the SVG viewport.

graphicsResolution float

The graphics resolution (pixels per inch).

Returns

System.Drawing.RectangleF

The content bounds of the resulting image.

Measure(RectangleF)

Calculates the content bounds of an SVG document, resizing the SVG viewport to fit into a specified rectangle.

public RectangleF Measure(RectangleF viewportRect)

Parameters

viewportRect System.Drawing.RectangleF

The target rectangle for the SVG viewport.

Returns

System.Drawing.RectangleF

The content bounds of the resulting image.

RegisterNamespacePrefix(string, string)

Registers prefix as a namespace prefix for the ns namespace.

public void RegisterNamespacePrefix(string prefix, string ns)

Parameters

prefix string

The prefix to register.

ns string

The target namespace.

Exceptions

System.ArgumentNullException

Save(Stream, XmlWriterSettings)

Saves the current GcSvgDocument to a System.IO.Stream in SVG format.

public void Save(Stream stream, XmlWriterSettings settings = null)

Parameters

stream System.IO.Stream

The output stream.

settings System.Xml.XmlWriterSettings

The output XML formatting settings.

Save(TextWriter, XmlWriterSettings)

Saves the current GcSvgDocument to a System.IO.TextWriter in SVG format.

public void Save(TextWriter tw, XmlWriterSettings settings = null)

Parameters

tw System.IO.TextWriter

The output System.IO.TextWriter.

settings System.Xml.XmlWriterSettings

The output XML formatting settings.

Save(string, XmlWriterSettings)

Saves the current GcSvgDocument to a file in SVG format.

public void Save(string path, XmlWriterSettings settings = null)

Parameters

path string

The output file path.

settings System.Xml.XmlWriterSettings

The output XML formatting settings.

Save(StringBuilder, XmlWriterSettings)

Saves the current GcSvgDocument to a System.Text.StringBuilder in SVG format.

public void Save(StringBuilder sb, XmlWriterSettings settings = null)

Parameters

sb System.Text.StringBuilder

The output System.Text.StringBuilder.

settings System.Xml.XmlWriterSettings

The output XML formatting settings.

ToSvgz()

Saves the current GcSvgDocument to a byte array in SVGZ format.

public byte[] ToSvgz()

Returns

byte[]

UnregisterNamespacePrefix(string)

Unregisters a specified namespace prefix.

public bool UnregisterNamespacePrefix(string prefix)

Parameters

prefix string

The prefix to unregister.

Returns

bool

true if the prefix was successfully unregistered, false otherwise.

Exceptions

System.ArgumentNullException