Aspose.SVG   for .NET

C# API to Parse SVG Files

Create, load, parse, render and convert SVG files to popular formats without any software dependencies

  Download Free Trial

Aspose.SVG for .NET is a flexible library for SVG file processing and fully compatible with its specifications. API can easily load, save and convert SVG files as well as read and traverse the elements of files through its Document Object Model (DOM). API is independent of any other software and empowers developers to work with SVG files without going into the underlying details of the format.

Using Aspose.SVG C# library in your project allows you to perform the following tasks:

Advanced .NET SVG Parsing API Features

Create and read SVG documents

Edit and Save SVG files

Full control over SVG nodes

Change the node properties

Content navigation using XPath Query

Navigate via CSS Selectors, Element and Document Traversal

DOM Tree manipulation of official SVG specifications

Convert SVG using C#

Aspose.SVG for .NET can read and convert SVG to PDF, XPS and major image formats. The conversion process is simple and reliable, thus making SVG .NET API a perfect choice. You can use API in your C# or any other .NET application to develop converter applications without getting into the details of underlying file formats. Getting conversion functionality is simple and depends on each application requirement. Here are a few lines of code for conversion between formats.

Convert SVG to PNG - C#

using Aspose.Svg;
using System.IO;
using Aspose.Svg.Saving;
using Aspose.Svg.Converters;
    // Initialize an SVG document from a file
    using (var document = new SVGDocument("input.svg"))
    	// Create an instance of the ImageSaveOptions class
    	var pngSaveOptions = new ImageSaveOptions();    
        // Convert SVG to PNG
    	Converter.ConvertSVG(document, pngSaveOptions, "output.png");

You can try online SVG Converter here.

Other Supported SVG Conversions:

Convert Raster Image to Vector Graphic

Converting an image to vector is very easy using Aspose.SVG API. The ImageVectorization Namespace includes classes and interfaces for implementing the image vectorization process. The following code snippet demonstrates the use of the ImageVectorizer class for image vectorization:

Convert Image to Vector - C#

using Aspose.Svg.ImageVectorization;
using Aspose.Svg.Saving;
	// Initialize an instance of the ImageVectorizer class
	var vectorizer = new ImageVectorizer
		Configuration = 
			TraceSmoother =   new ImageTraceSmoother(1),
			TraceSimplifier = new ImageTraceSimplifier(0.5f),
			ColorsLimit = 3
	// Vectorize raster image from the specified file
	using var document = vectorizer.Vectorize("input.png");
	// Save vectorized image as SVG file 

You can try online Image Vectorizer here.

Other Supported Vectorizers:

Merge SVG in C#

The Renderer() method gives you the ability to send multiple documents at once to the output rendering device and merge them. Documents merging can be done with a few lines of code:

Merge SVG to PDF - C#

using Aspose.Svg;
using Aspose.Svg.Rendering;
using Aspose.Svg.Rendering.Pdf;
	// Initialize SVG documents from files to merge later
	using (var document1 = new SVGDocument("input1.svg"))
	using (var document2 = new SVGDocument("input2.svg"))
	using (var document3 = new SVGDocument("input3.svg"))
		// Create an instance of SvgRenderer
		using (var renderer = new SvgRenderer())
			// Create an instance of PdfDevice
			using (var device = new PdfDevice("output.pdf"))
				// Merge all SVG documents to PDF
				renderer.Render(device, document1, document2, document3);

Other Supported Mergers:


Support and Learning Resources