Class SvgDocument
The class used to create and load SVG documents.
Implements
System.ComponentModel.ITypeDescriptorContext
Inherited Members
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()
Declaration
Properties
|
Improve this Doc
View Source
BaseUri
Declaration
public Uri BaseUri { get; set; }
Property Value
|
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
|
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
Declaration
protected virtual SvgElementIdManager IdManager { get; }
Property Value
|
Improve this Doc
View Source
Overflow
Declaration
public override SvgOverflow Overflow { get; }
Property Value
Overrides
|
Improve this Doc
View Source
PointsPerInch
Declaration
public static int PointsPerInch { get; set; }
Property Value
|
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
|
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
|
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
|
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
|
Improve this Doc
View Source
SkipGdiPlusCapabilityCheck
Skip check whether the GDI+ can be loaded.
Declaration
public static bool SkipGdiPlusCapabilityCheck { get; set; }
Property Value
|
Improve this Doc
View Source
X
Declaration
public override SvgUnit X { get; }
Property Value
Overrides
|
Improve this Doc
View Source
Y
Declaration
public override SvgUnit Y { get; }
Property Value
Overrides
Methods
|
Improve this Doc
View Source
Draw()
Declaration
public virtual Bitmap Draw()
Returns
| Type |
Description |
| Bitmap |
A containing the rendered document.
|
|
Improve this Doc
View Source
Draw(Bitmap)
Declaration
public virtual void Draw(Bitmap bitmap)
Parameters
| Type |
Name |
Description |
| Bitmap |
bitmap |
|
|
Improve this Doc
View Source
Draw(Graphics)
Declaration
public void Draw(Graphics graphics)
Parameters
| Type |
Name |
Description |
| Graphics |
graphics |
The to be rendered to.
|
Exceptions
|
Improve this Doc
View Source
Draw(Graphics, Nullable<SizeF>)
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
|
Improve this Doc
View Source
Draw(ISvgRenderer)
Declaration
public void Draw(ISvgRenderer renderer)
Parameters
Exceptions
|
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 Parameters
|
Improve this Doc
View Source
GetElementById(String)
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
|
Improve this Doc
View Source
GetElementById<TSvgElement>(String)
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
Exceptions
|
Improve this Doc
View Source
Open(XmlDocument)
Declaration
public static SvgDocument Open(XmlDocument document)
Parameters
Returns
Exceptions
|
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 Parameters
|
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 Parameters
Exceptions
|
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 Parameters
Exceptions
|
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
Exceptions
|
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
Exceptions
|
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
Exceptions
|
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 Parameters
|
Improve this Doc
View Source
OpenAsBitmap(String)
Declaration
public static Bitmap OpenAsBitmap(string path)
Parameters
| Type |
Name |
Description |
| System.String |
path |
|
Returns
|
Improve this Doc
View Source
OpenAsBitmap(XmlDocument)
Declaration
public static Bitmap OpenAsBitmap(XmlDocument document)
Parameters
Returns
|
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
|
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
|
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
|
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
|
Improve this Doc
View Source
WriteAttributes(XmlWriter)
Declaration
protected override void WriteAttributes(XmlWriter writer)
Parameters
| Type |
Name |
Description |
| System.Xml.XmlWriter |
writer |
|
Overrides
Explicit Interface Implementations
|
Improve this Doc
View Source
ITypeDescriptorContext.Container
Declaration
IContainer ITypeDescriptorContext.Container { get; }
Returns
|
Improve this Doc
View Source
ITypeDescriptorContext.Instance
Declaration
object ITypeDescriptorContext.Instance { get; }
Returns
|
Improve this Doc
View Source
ITypeDescriptorContext.OnComponentChanged()
Declaration
void ITypeDescriptorContext.OnComponentChanged()
|
Improve this Doc
View Source
ITypeDescriptorContext.OnComponentChanging()
Declaration
bool ITypeDescriptorContext.OnComponentChanging()
Returns
|
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
Implements
System.ComponentModel.ITypeDescriptorContext
Extension Methods