Supported Features
Key Features
Aspose.SVG for .NET has been developed keeping in view .NET application developers who would love to write applications for editing SVG files. The API is fully compatible with the SVG official specifications and empowers you to work with SVG files without going into the underlying details of the SVG file format. SVG C# Library has multiple key features that include DOM tree manipulation, content navigation with the help of XPath Query, CSS Selectors, Quality rendering and converting to formats PDF, XPS, JPEG, PNG, BMP, GIF, TIFF and creation of SVG documents from scratch.
Aspose.SVG for .NET aims high at facilitating its users for working with SVG files. Key features supported by the API include:
SVG Document Creation and Loading
- Create an Empty SVG Document – Instantiate an empty SVG document using the
SVGDocument()
constructor. - Load SVG from Memory, Stream, or File – The
SVGDocument
class has a wide set of overloaded constructors allowing you to create a blank document or load SVG from a file, URL, stream, etc. - Load SVGZ from File or URL – Load existing SVGZ files using
SVGDocument
class. - Read SVG with Resources Async – Asynchronously load SVG with external resources using the
OnReadyStateChange
event handler. - Create SVG with Builder API – Use the SVG Builder API to programmatically construct and configure SVG elements with precision and efficiency.
SVG Document Editing
- Edit a Document Tree – DOM tree manipulation based on official SVG specifications.
- Add Elements to SVG – Use
CreateElementNS()
andInsertBefore()
to programmatically insert new SVG elements into the document. - Draw Basic Shapes – Add geometric primitives like
<circle>
,<rect>
, and<line>
to create custom vector graphics. - Edit SVG Using SVG Builder – Edit SVG elements to change styles, positions, and other properties using Element Builders, a powerful technique for programmatically editing SVG.
- Edit SVG Paths – Access and update complex path definitions with full control over curves, lines, and commands.
SVG Document Navigation and Inspection
- DOM-Based Navigation – Traverse the SVG structure using familiar DOM methods and properties such as
GetElementsByTagName()
,DocumentElement
, and node relationships to explore and manipulate content. - Element Inspection – Access and extract detailed information from individual SVG elements using DOM properties.
- CSS Selectors – Select and edit elements using CSS selector syntax to apply styles or make targeted changes through the API.
- XPath Queries – Use powerful XPath expressions to locate and interact with nodes in the SVG document for advanced search and inspection tasks.
SVG Builder API
- SVG Builder API – Simplify the creation and maintenance of SVGs, enhancing code readability and making it easier to understand and modify.
- SVGElementBuilder – Create and configure SVG elements like
<rect>
,<circle>
,<text>
, and more using a fluent syntax for faster and cleaner SVG creation. - Path Builder – Define complex vector paths programmatically with precision using the
PathBuilder
class. - Paint Builder – Easily apply fill, stroke, gradients, and opacity settings to SVG elements, allowing fine control over styling and visual appearance.
SVG Conversion and Rendering
- Convert SVG to PDF, XPS, and images – Convert SVG files to formats like PDF, XPS, PNG, JPEG, TIFF, WEBP, or GIF.
- Convert SVG to SVGZ and Back – Choose between compressed (SVGZ) and uncompressed (SVG) formats using the
SVGSaveFormat
enumeration in theAspose.Svg.Saving
namespace. - Advanced Rendering Options – Fine-tune rendering with settings such as resolution, protection, background color, and page size using
ImageRenderingOptions
,PdfRenderingOptions
, orXpsRenderingOptions
, depending on your output format.
Image Vectorization and Text Vectorization
- Image Vectorization – Vectorization of raster images such as PNG, JPG, BMP, TIFF, GIF, and ICO into an SVG document.
- Image Stencil Effects – Generate stylized, stencil-like visuals from images during vectorization for creative or technical uses.
- Text Vectorization – Convert text nodes into path elements to preserve appearance, prevent text editing, and maintain crisp rendering at any zoom level.
Advanced SVG Features
- Merge Multiple SVGs – Combine multiple SVG documents into a single file using the
Render()
method and save the result as PDF, XPS, or Image. - Apply SVG Transformations – Transform individual or grouped SVG elements with rotation, scaling, translation, and skewing using the
transform
attribute or transformation matrices. - SVG Optimization – Optimize SVG files by removing redundant elements, attributes, and metadata to reduce file size and improve performance.
- SVG Filters – Apply SVG filters like Gaussian blur, drop shadow, color saturation, and more through code.
- SVG Gradients – Create and apply smooth color transitions using linear and radial gradients to enrich SVG graphics with dynamic color effects.
- SVG Text and Fonts – Manipulate text using SVG-specific tags like
<text>
,<tspan>
. - Logging and Message Handlers – Implement detailed logging and monitor network requests or errors using customizable message handlers like
LogMessageHandler
for enhanced diagnostics and debugging. - Built-in features – CSS and JS – Manipulate stylesheets, inline and external styles for entire documents or targeted elements; execute JavaScript code embedded in SVG documents.
Conclusions
- Aspose.SVG for .NET, with full SVG standards compliance and integration with modern .NET frameworks, provides efficiency and ease of use for both simple and complex SVG workflows.
- The library supports DOM manipulation, rendering customization, cross-platform deployment, and advanced features such as filters, gradients, transformations, and conversions, making it ideal for professional-grade applications.