Aspose.SVG 24.12.0

dotnet add package Aspose.SVG --version 24.12.0                
NuGet\Install-Package Aspose.SVG -Version 24.12.0                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Aspose.SVG" Version="24.12.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Aspose.SVG --version 24.12.0                
#r "nuget: Aspose.SVG, 24.12.0"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Aspose.SVG as a Cake Addin
#addin nuget:?package=Aspose.SVG&version=24.12.0

// Install Aspose.SVG as a Cake Tool
#tool nuget:?package=Aspose.SVG&version=24.12.0                

Create, Modify, & Convert SVG via .NET API

Version 24.12.0 NuGet .NET

banner


Product Page Docs Reference Examples Blog Releases Support License


Aspose.SVG for .NET is a powerful API designed to work with SVG documents in .NET applications. It allows developers to create, manipulate, and convert SVG files into various formats like PDF, PNG, TIFF, and more. The API supports SVG vectorization, custom configuration, document merging, transformations, and advanced features like gradients, filters, and path building. Perfect for developers aiming to enhance graphical content and automate SVG workflows in .NET environments.

SVG Document Creation and Loading

  • Create an Empty SVG Document: Use the SVGDocument() constructor to create a blank SVG document.
  • Create SVG from Memory String: Create an SVG file from a memory string using SVGDocument() constructors.
  • Create SVG from a Stream: Load SVG from different streams like memory or file using overloaded SVGDocument() constructors.
  • Create Custom SVG with Builder API: Use SVG Builder API to build custom SVG elements.
  • Load SVG from File: Load existing SVG files using SVGDocument(Path) method.
  • Load SVG from Web: Load SVG from a web URL into an SVG document using Navigate() method.
  • Read SVG with Resources Async: Asynchronously load SVG with external resources using the OnReadyStateChange event handler.

SVG Document Editing and Modification

  • Add Elements to SVG: Insert new SVG elements using CreateElementNS() method and InsertBefore() to append nodes.
  • Add Basic Shapes to SVG: Add geometric shapes like circles and rectangles.
  • Edit Existing Elements: Modify elements in the DOM using SetAttribute(), GetAttribute(), and other methods.
  • SVG Drawing on Bitmap: Draw and modify an SVG directly on a bitmap image using the rendering engine.
  • Edit SVG Path: Update and customize path elements using the path API.

SVG Document Navigation and Inspection

  • Navigation using DOM: Traverse and inspect SVG elements using DOM methods like DocumentElement, GetElementsByTagName(), and more.
  • Inspect Specific Elements: Extract detailed information about individual elements within an SVG using DOM properties.
  • Use CSS Selector for Editing: Modify and style SVG elements using CSS Selectors within the API.
  • XPath Query Navigation: Use XPath queries to navigate through nodes in the SVG document.

SVG Conversion and Rendering

  • Convert SVG to PDF: Use the ConvertSVG() method to export SVG to PDF.
  • Convert SVG to XPS: Use ConvertSVG() method to convert SVG into XPS format.
  • Convert SVG to Image Formats: Export SVG documents to image formats like PNG, JPG, BMP, TIFF, and GIF.
  • Rendering Options: Set rendering options such as background color, resolution, and page size using ImageRenderingOptions, PdfRenderingOptions, and XpsRenderingOptions.

SVG Vectorization and Optimization

  • Image Vectorization: Convert raster images like PNG, JPG, BMP into scalable vector graphics using the ImageVectorizer class.
  • Text Vectorization: Convert text within SVG into vectorized paths to protect against modifications and ensure high-quality rendering.
  • SVG Optimization: Reduce the file size and clean up the SVG by removing unnecessary elements and attributes.

SVG Document Merging and Transformation

  • Merge Multiple SVGs: Combine multiple SVG documents into a single file using the Render() method.
  • Apply SVG Transformations: Perform transformations like rotation, scaling, and skewing on SVG elements.
  • Apply Filters and Gradients: Use SVG filters like Gaussian blur, drop shadow, and more to enhance graphical content.

Environment Configuration

  • Custom Configuration: Create and apply custom configuration settings for runtime services, web requests, and more.
  • Logging and Message Handlers: Set up logging of network requests and errors using LogMessageHandler.

Advanced SVG Features

  • SVG Filters: Apply SVG filters like Gaussian blur and color saturation through code.
  • SVG Gradients: Create and apply gradients (linear, radial) within SVG files.
  • SVG Transformations: Perform and combine transformations like rotation, scaling, and skewing on SVG elements.
  • SVG Text and Fonts: Manipulate text using SVG-specific tags like <text>, <tspan>, and apply glyphs and fonts.

SVG Builder API

  • SVGElementBuilder: Create new SVG elements through a fluent API.
  • Path Builder: Customize SVG paths programmatically for accurate rendering.
  • Paint Builder: Apply stroke and fill attributes to SVG elements efficiently.

Supported File Formats

Format Description Load Save
SVG Scalar Vector Graphics Format ✔️
PDF Portable Document Format ✔️
XPS XML Paper Specification ✔️
TIFF Tagged Image File Format ✔️
BMP Bitmap Image File Format ✔️
PNG Portable Network Graphics ✔️
JPEG Joint Photographic Expert Group ✔️
GIF Graphical Interchange Format ✔️

System Requirements

To build and manipulate SVG documents, the machine running Aspose.SVG for .NET does not require modeling and rendering software installed. Aspose.SVG for .NET includes a document generation engine.

Category Details
Supported Operating System
Windows - Microsoft Windows Server 2022 (x64), - Microsoft Windows 2019 Server (x64), - Microsoft Windows 2016 Server (x64), - Microsoft Windows Server 2012 R2 (x64), - Microsoft Windows Server 2012 (x64), - Microsoft Windows Server 2008 R2 SP1 (x64), - Microsoft Windows Server 2008 SP2 (x64, x86), - Microsoft Windows 11 (x64), - Microsoft Windows 10 (x64, x86), - Microsoft Windows 8.1 (x64, x86), - Microsoft Windows 8 (x64, x86), - Microsoft Windows 7 SP1 (x64, x86), - Microsoft Azure
macOS - Mac OS X x64 (10.12+)
Linux - Linux x64 (6, 7, 27, 9, 8.7+, 18.04, 16.04, 14.04, 18, 17, 42.3+, 12 SP2+)
Development Environments - Microsoft Visual Studio 2010, - Microsoft Visual Studio 2011, - Microsoft Visual Studio 2012, - Microsoft Visual Studio 2013, - Microsoft Visual Studio 2015, - Microsoft Visual Studio 2017, - Microsoft Visual Studio 2019
Supported Frameworks .NET Standard 2.0, Compatible with: - .NET Framework 4.6.1+, - .NET Standard 2.0/2.1, - .NET Core 2.0+, - .NET 5.0+

Steps to Install Aspose.SVG for .NET through NuGet

1. Open Visual Studio Project

  • Open your solution or project in Visual Studio.

2. Install NuGet Package Manager (if needed)

  • Go to Tools > Extension Manager.
  • Search for "NuGet Package Manager" in the Online Gallery.
  • Download and install it.
  • Restart Visual Studio.

3. Install Aspose.SVG using Package Manager Console

  • Open Tools > Library Package Manager > Package Manager Console.
  • Type Install-Package Aspose.SVG for the latest version or Install-Package Aspose.SVG -prerelease for the latest release with hotfixes.
  • Press Enter.

4. Update Aspose.SVG via Package Manager Console

  • Open the Package Manager Console again.
  • Type Update-Package Aspose.SVG to update to the latest release, or use -prerelease for hotfixes.

5. Install/Update Using GUI

  • Go to Tools > Library Package Manager > Manage NuGet Packages or right-click the project name in Solution Explorer.
  • Search for Aspose.SVG in the online package search.
  • Click Install/Update next to the latest version of Aspose.SVG for .NET.

Create Custom SVG Paths Programmatically

Learn how to create SVG paths using the Aspose.SVG for .NET API. Add and customize path elements with attributes for precision in rendering vector graphics.

// Create an SVG path element using Aspose.SVG for .NET
var pathElement = (SVGPathElement)document.CreateElementNS(SvgNamespace, "path");

// Create and configure SVG path segments
SVGPathSeg pathSeg1 = pathElement.CreateSVGPathSegMovetoAbs(10, 200);
SVGPathSeg pathSeg2 = pathElement.CreateSVGPathSegCurvetoQuadraticAbs(180, 200, 25, 210);
SVGPathSeg pathSeg3 = pathElement.CreateSVGPathSegCurvetoQuadraticSmoothAbs(300, 250);
SVGPathSeg pathSeg4 = pathElement.CreateSVGPathSegCurvetoQuadraticSmoothAbs(420, 250);
SVGPathSeg pathSeg5 = pathElement.CreateSVGPathSegCurvetoQuadraticSmoothAbs(490, 150);

// Append segments to the path
pathElement.PathSegList.AppendItem(pathSeg1);
pathElement.PathSegList.AppendItem(pathSeg2);
pathElement.PathSegList.AppendItem(pathSeg3);
pathElement.PathSegList.AppendItem(pathSeg4);
pathElement.PathSegList.AppendItem(pathSeg5);

// Set stroke and fill attributes for the path
pathElement.SetAttribute("stroke", "magenta");
pathElement.SetAttribute("fill", "none");
pathElement.SetAttribute("stroke-width", "4");

// Insert the path element into the SVG document
svgElement.InsertBefore(pathElement, svgElement.FirstChild);

Convert SVG to PNG Easily Using Aspose.SVG for .NET

Quickly convert SVG files to PNG images using the Aspose.SVG for .NET API. A simple solution for rendering high-quality PNGs from SVG documents.

// Load the SVG document from a file
using (var document = new SVGDocument(Path.Combine(DataDir, "owl.svg")))
{
    // Initialize the SvgRenderer to render the document
    using (var renderer = new SvgRenderer())
    {
        // Create an ImageDevice to save the rendered output as PNG
        using (var device = new ImageDevice(Path.Combine(OutputDir, "owl.png")))
        {
            // Render the SVG document to PNG format
            renderer.Render(device, document);
        }
    }
}

Merge Multiple SVG Documents into a Single PDF

Combine multiple SVG files into a single PDF with the Aspose.SVG for .NET API. This guide shows how to render multiple SVG documents into one PDF file.

// Load multiple SVG documents from files
using (var document1 = new SVGDocument(Path.Combine(DataDir, "circle.svg")))
using (var document2 = new SVGDocument(Path.Combine(DataDir, "flower.svg")))
using (var document3 = new SVGDocument(Path.Combine(DataDir, "lineto.svg")))
{
    // Initialize the SvgRenderer for rendering multiple SVGs
    using (var renderer = new SvgRenderer())
    {
        // Create a PdfDevice to save the output as a PDF
        using (var device = new PdfDevice(Path.Combine(OutputDir, "result.pdf")))
        {
            // Render and merge all SVG documents into a single PDF
            renderer.Render(device, document1, document2, document3);
        }
    }
}

Product Page Docs Reference Examples Blog Releases Support License


Tags

SVG Creation | SVG Conversion | SVG Manipulation | Vector Graphics | Image Vectorization | Text Vectorization | SVG Optimization | SVG to PDF | SVG to PNG | Image Conversion | Rendering Options | Custom Configuration | CSS Selector | XPath Navigation | SVG Filters | SVG Gradients | SVG Transformations | Advanced SVG Features | SVG to XPS | Document Merging | SVG Builder API | High-Quality Rendering | Bitmap Rendering | Path Builder | PDF Export | SVG Document Navigation | Logging and Message Handlers | Image Formats

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Aspose.SVG:

Package Downloads
Aspose.Total

Aspose.Total for .NET is the most complete package of all .NET file format APIs offered by Aspose. It empowers developers to create, edit, render, print and convert between a wide range of popular document formats within any .NET, C#, ASP.NET and VB.NET applications.

Aspose.SVG.Drawing.SkiaSharp

ABOUT Aspose.SVG.Drawing.SkiaSharp is an extension component for Aspose.SVG that enhances its functionality by leveraging the SkiaSharp library for drawing and comprehensive conversion of SVG files. It supports conversion to popular raster formats such as PNG, JPEG, and TIFF, as well as providing robust capabilities for converting SVG files to PDF and XPS formats. By utilizing SkiaSharp, this component offers faster drawing capabilities and multiplatform support. It seamlessly integrates into your .NET Apps and extends Aspose.SVG's capabilities to enable high-quality SVG rendering and conversion using SkiaSharp's powerful features. SkiaSharp provides a wide range of advanced image filters, shaders, and other capabilities that are leveraged by Aspose.SVG.Drawing.SkiaSharp for drawing SVG documents, enabling image effects and manipulations, such as blurring, sharpening, color adjustments, gradients, and custom shader effects. These features enhance the visual output of your SVG files, resulting in visually enhanced and engaging graphics. Aspose.SVG.Drawing.SkiaSharp is developed for .NET Standard 2.0, making it compatible with a wide range of .NET platforms. It can be used with any .NET language, including C# and VB.NET. It works on multiple operating systems, including MS Windows (32-bit and 64-bit), macOS (10.12+), and Linux, wherever you can install .NET Framework, Mono, or .NET Core. HOW TO USE To activate the Aspose.SVG.Drawing.SkiaSharp feature, simply include the following code in your application: Aspose.Svg.Configuration.SetExtension(new SkiaModule()); With the drawing engine initialized, you can now use the Aspose.SVG.Drawing.SkiaSharp for various tasks. For instance, you can convert SVG files to PNG as shown below: using Aspose.Svg; using System.IO; using Aspose.Svg.Saving; using Aspose.Svg.Converters; using Aspose.Svg.Drawing.SkiaSharp; // Initilize SkiaSharp-based drawing engine Aspose.Svg.Configuration.SetExtension(new SkiaModule()); // Initialize an SVG document from a file using (var document = new SVGDocument(Path.Combine(DataDir, "source.svg"))) { // Create an instance of the ImageSaveOptions class var pngSaveOptions = new ImageSaveOptions(); // Convert SVG to PNG Converter.ConvertSVG(document, pngSaveOptions, Path.Combine(OutputDir, "result.png")); }

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
24.12.0 219 12/18/2024
24.11.0 1,530 11/27/2024
24.10.0 6,313 10/30/2024
24.9.0 6,094 9/19/2024
24.8.0 3,643 8/22/2024
24.7.0 2,748 7/18/2024
24.6.0 5,290 6/17/2024
24.5.0 9,695 5/3/2024
24.4.0 5,201 4/5/2024
24.3.0 5,680 3/6/2024
24.2.0 5,436 2/10/2024
24.1.0 7,094 1/18/2024
23.12.0 7,398 12/16/2023
23.11.0 1,624 12/3/2023
23.10.0 27,708 10/25/2023
23.9.0 12,978 9/18/2023
23.8.1 107,520 8/12/2023
23.7.0 8,789 7/27/2023
23.6.0 9,766 6/29/2023
23.5.0 8,542 5/25/2023
23.4.0 33,180 4/19/2023
23.3.0 14,973 3/21/2023
23.2.0 8,540 2/28/2023
23.1.0 40,339 1/31/2023
22.12.0 2,672 1/17/2023
22.11.0 21,879 11/25/2022
22.10.0 7,307 10/31/2022
22.9.0 20,032 9/30/2022
22.8.0 21,262 8/30/2022
22.7.0 15,560 7/27/2022
22.6.0 18,083 6/21/2022
22.5.0 8,834 5/20/2022
22.4.0 9,999 4/21/2022
22.3.0 14,085 3/12/2022
22.2.0 13,752 2/17/2022
22.1.0 7,620 1/16/2022
21.12.0 8,408 12/3/2021
21.11.0 9,037 11/3/2021
21.10.0 7,563 10/12/2021
21.9.0 17,916 9/7/2021
21.8.0 11,959 8/5/2021
21.7.0 14,022 7/2/2021
21.6.0 3,677 6/3/2021
21.5.0 10,422 5/12/2021
21.4.0 20,191 4/9/2021
21.3.0 9,958 3/12/2021
21.2.0 10,469 2/10/2021
21.1.0 5,222 1/25/2021
20.12.0 4,462 12/14/2020
20.11.0 9,328 11/12/2020
20.10.0 3,139 10/29/2020
20.9.0 5,260 9/25/2020
20.8.0 4,424 8/21/2020
20.7.0 24,116 7/31/2020
20.6.0 3,473 6/30/2020
20.5.0 3,323 5/29/2020
20.4.0 10,690 4/28/2020
20.2.0 3,721 2/27/2020
20.1.0 3,094 1/30/2020