[]
Represents an SVG document.
public class GcSvgDocument : IDisposable
Initializes an empty instance of the GcSvgDocument class.
public GcSvgDocument()
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; }
Gets or sets the currentColor value used by the SVG renderer.
public SvgColor? CurrentColor { get; set; }
Gets or sets the list of font names belonging to the Cursive font family.
public List<string> CursiveFonts { get; set; }
Gets the default list of font names belonging to the Cursive font family.
public static List<string> DefaultCursiveFonts { get; }
Gets the default list of font names belonging to the Fantasy font family.
public static List<string> DefaultFantasyFonts { get; }
Gets the default list of font names belonging to the Serif font family.
public static List<string> DefaultMonospaceFonts { get; }
Gets the default list of font names belonging to the SansSerif font family.
public static List<string> DefaultSansSerifFonts { get; }
Gets the default list of font names belonging to the Serif font family.
public static List<string> DefaultSerifFonts { get; }
Gets or sets the list of font names belonging to the Fantasy font family.
public List<string> FantasyFonts { get; set; }
Gets or sets the custom font collection used for searching fonts and font fallbacks.
public FontCollection FontCollection { get; set; }
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; }
Gets a value indicating whether the GcSvgDocument has been disposed of.
public bool IsDisposed { get; }
Gets or sets the list of font names belonging to the Monospace font family.
public List<string> MonospaceFonts { get; set; }
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; }
Gets the root SVG element.
public SvgSvgElement RootSvg { get; }
Gets or sets the list of font names belonging to the SansSerif font family.
public List<string> SansSerifFonts { get; set; }
Gets or sets the list of font names belonging to the Serif font family.
public List<string> SerifFonts { get; set; }
Removes all namespace prefixes except "svg", "xlink", and "xml".
public void ClearNamespacePrefixes()
Releases unmanaged resources used by this object.
public void Dispose()
Creates a new GcSvgDocument from a specified SVG file.
public static GcSvgDocument FromFile(string path)
path
stringThe SVG file path.
The created SVG document.
Creates a new GcSvgDocument from a specified SVG data stream, optionally leaving the stream open.
public static GcSvgDocument FromStream(Stream stream, bool leaveOpen)
stream
System.IO.StreamThe stream containing the SVG data.
leaveOpen
booltrue to leave the stream open after reading the data, false to close the stream.
The created SVG document.
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)
stream
System.IO.StreamThe stream containing the SVG data.
The created SVG document.
Creates a new GcSvgDocument from a specified SVG string data.
public static GcSvgDocument FromString(string svgData)
svgData
stringThe string containing the SVG data.
An SVG document that was created.
Creates a new GcSvgDocument from binary data in SVGZ format.
public static GcSvgDocument FromSvgz(byte[] svgzData)
svgzData
byte[]A byte array containing the SVG data packed with GZ format (see RFC 1952).
An SVG document that was created.
Gets an SvgElement with the specified id
, or null if nothing was found.
public SvgElement GetElementByID(string id)
id
stringGets a list of SvgElements with the specified className
.
public IReadOnlyList<SvgElement> GetElementsByClass(string className)
className
stringCalculates the intrinsic size of the SVG viewport, in specified units
.
The following units are supported:
public SizeF GetIntrinsicSize(SvgLengthUnits units)
units
SvgLengthUnitsThe intrinsic size of SVG viewport, or System.Drawing.SizeF.Empty if the size is undefined.
Searches for a namespace with a specified prefix.
public string GetNamespaceByPrefix(string prefix)
prefix
stringThe prefix to search for.
The namespace with the specified prefix, or null.
Returns an array with all registered namespace prefixes.
public string[] GetNamespacePrefixes()
Searches for a prefix associated with a specified namespace.
public string GetPrefixByNamespace(string ns)
ns
stringThe namespace to search for.
The prefix associated with the specified namespace, or null.
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)
viewportPosition
System.Drawing.PointFThe coordinates for the top-left corner of the SVG viewport.
graphicsResolution
floatThe graphics resolution (pixels per inch).
The content bounds of the resulting image.
Calculates the content bounds of an SVG document, resizing the SVG viewport to fit into a specified rectangle.
public RectangleF Measure(RectangleF viewportRect)
viewportRect
System.Drawing.RectangleFThe target rectangle for the SVG viewport.
The content bounds of the resulting image.
Registers prefix
as a namespace prefix for the ns
namespace.
public void RegisterNamespacePrefix(string prefix, string ns)
prefix
stringThe prefix to register.
ns
stringThe target namespace.
Saves the current GcSvgDocument to a System.IO.Stream in SVG format.
public void Save(Stream stream, XmlWriterSettings settings = null)
stream
System.IO.StreamThe output stream.
settings
System.Xml.XmlWriterSettingsThe output XML formatting settings.
Saves the current GcSvgDocument to a System.IO.TextWriter in SVG format.
public void Save(TextWriter tw, XmlWriterSettings settings = null)
tw
System.IO.TextWriterThe output System.IO.TextWriter.
settings
System.Xml.XmlWriterSettingsThe output XML formatting settings.
Saves the current GcSvgDocument to a file in SVG format.
public void Save(string path, XmlWriterSettings settings = null)
path
stringThe output file path.
settings
System.Xml.XmlWriterSettingsThe output XML formatting settings.
Saves the current GcSvgDocument to a System.Text.StringBuilder in SVG format.
public void Save(StringBuilder sb, XmlWriterSettings settings = null)
sb
System.Text.StringBuilderThe output System.Text.StringBuilder.
settings
System.Xml.XmlWriterSettingsThe output XML formatting settings.
Saves the current GcSvgDocument to a byte array in SVGZ format.
public byte[] ToSvgz()
Unregisters a specified namespace prefix.
public bool UnregisterNamespacePrefix(string prefix)
prefix
stringThe prefix to unregister.
true if the prefix was successfully unregistered, false otherwise.