C# SVG API, Create edit convert SVG files

Its time to announce the addition of the C# SVG library to our product line - Aspose.SVG for .NET. It is a .NET class library that lets you create, edit, read and convert SVG files programmatically using C# in .NET or .NET Core based applications. Let’s have a quick walk through the installation methods and salient features of the API.

C# .NET SVG API - Installation

Aspose.SVG for .NET DLL can be downloaded from our Downloads section. On the other hand, you can install it via NuGet Package Manager or the Package Manager Console in Visual Studio.

NuGet Package Manager

C# .NET SVG library

Package Manager Console

PM> Install-Package Aspose.SVG

Let’s now have a glance at some salient features of the API to deal with SVG files.

Create an SVG File using C#

Aspose.SVG for .NET lets you create an empty file having an SVG structure. Furthermore, you can also create an SVG file from a user-defined string. The API provides SVGDocument class to create SVG files and you can further use this object to fill the document with SVG elements. Once done, you can save the file using SVGDocument.Save() method. The following code samples show how to create an SVG file from scratch.

Create Empty SVG File in C#

Create SVG with User Defined String in C#

Edit SVG Files in C#

Aspose.SVG for .NET also allows you to edit the SVG files to update their content. The API’s Data Object Model efficiently maps the official specifications of SVG to access and edit SVG nodes and their elements. The following code sample shows how to edit an SVG file in C#.

Read SVG Files in C#

In case you would want to read an existing SVG file, you can load it using the SVGDocument class. Simply create a new object and initialize it with SVG file’s path as shown in the following code sample.

Convert SVG Files to PSD, XPS or Raster Images

You can also convert the SVG files to various other file formats. The supported conversions include:

  • SVG to PDF
  • SVG to XPS
  • SVG to Image (JPEG, PNG, BMP, GIF, TIFF)

The following code sample shows how to convert an SVG file to PDF in C#.

For code samples of SVG to XPS and SVG to image, please visit Converting SVG Files in C#.

Learn more about .NET SVG API

You can evaluate the API’s features by downloading the examples project. For more details, consult the documentation of the API. In case you would have any questions or queries, feel free to let us know via our forum.

See Also