SVG Conversion Via C#
Convert SVG to PDF, XPS, and Images including BMP, JPEG, PNG, TIFF, and GIF online or using C# library
How to Convert SVG Using C#
SVG (Scalable Vector Graphics) is an XML-based image format for two-dimensional graphics. It is a vector graphics format intended primarily for the Web. The main excellence of SVG is its unmatched ability to be scaled to any size without any shred of quality degradation. All modern browsers support SVG, and it would seem that the Web should already switch to vector graphics. However, there are some restrictions on the use of SVG and sometimes you need to convert SVG to other formats.
Aspose.SVG for .NET API makes the conversion process easier for developers. Converting between formats can perform by using a few different approaches:
The static Converter class is a shared facade that provides SVG file conversions to the popular formats and allows to make these operations convenient and easy.
The RenderTo() method is used to render SVG to another format and send a document to the output device. Aspose.SVG API provides the following output devices implementation: the PdfDevice, XpsDevice, and ImageDevice classes, which perform rendering to PDF, XPS, and Image file formats respectively.
Online SVG Converter
You can convert SVG with Aspose.SVG for .NET API in real-time. The following C# example demonstrates how to convert an SVG document. Please load a file from a local file system or URL, select the output format, and run the example. You will immediately get the result as a separate file.
using Aspose.Svg; using Aspose.Svg.Saving; using Aspose.Svg.Converters; using Aspose.Svg.Rendering.Image; using var document = new SVGDocument("{{input lower}}"); {{#if_output 'PDF'}} var options = new PdfSaveOptions(); {{/if_output}} {{#if_output 'XPS'}} var options = new XpsSaveOptions(); {{/if_output}} {{#if_output 'BMP' 'JPG' 'GIF' 'PNG' 'TIFF'}} var options = new ImageSaveOptions(ImageFormat.{{output param2 camel}}); {{/if_output}} Converter.ConvertSVG(document, options, "output.{{output lower}}");
Popular SVG Conversions in Documentation
Aspose.SVG for .NET library lets you create, edit, read and convert SVG files programmatically using C#. The main highlight of SVG C# API is a conversion feature. The Aspose.SVG.Converters namespace implements easy access to conversion methods. It provides a wide range of SVG conversions to popular formats, such as PDF, XPS, JPEG, PNG, BMP, TIFF, and GIF. Please visit the documentation chapter How to Convert SVG Files to learn more about SVG C# API conversion features.
Installing Aspose.SVG for .NET library
Aspose.SVG for .NET is a cross-platform flexible library that is designed to provide a wide range of features for processing and rendering SVG documents. It seamlessly integrates into your .NET Apps to work with SVG files without installing any 3rd party software. Our SVG .NET API can be used with any .NET language, such as C#, VB.NET, ASP.NET, etc. It works equally well on any OS that can install Mono (.NET 4.0 Framework support) or use .NET core. This includes Windows, Linux, and macOS.
Installing Aspose.SVG for .NET through NuGet :
- Using the Package Manager Console.
- Using the NuGet Package Manager GUI.
For more details about C# library installation, please refer to Aspose.SVG Documentation .
Other Supported Conversions
You can also convert SVG files into many other file formats including few listed below: