Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Converting SVG documents to other formats is one of the main features of Aspose.SVG for .NET API. Converting is required for various reasons: to work in a familiar, convenient format or to take advantage of different formats for specific tasks. The articles in this section provide information on a list of supported SVG conversion scenarios and how to execute them in C#.
Aspose.SVG for .NET API can convert SVG files to PDF, XPS, JPG, PNG, BMP, TIFF, and GIF file formats. You can use API in your C# or any other .NET application (such as VB.NET) to develop converter applications without getting into the details of underlying file formats.
You can convert SVG to other formats with Aspose.SVG API in real time. Please load SVG from the local file system, select the output format and run the example. In this example, the save options are set by default. You will immediately receive the result as a separate file.
You can convert SVG to various popular formats in any way – online or programmatically. Converting from SVG to other formats can perform by using
ConvertSVG() methods of the
Converter class, the
RenderTo(device) method of the
SVGDocument class, or the Render(IDevice, TDocument) method of the
Renderer class.
The current section describes supported scenarios of SVG files conversions to other popular formats by using Converter and SVGDocument classes:
IDevice, TDocument) method of the
Renderer class gives you the ability to send multiple documents at once to the output rendering device and merge them.Let’s consider both scenarios of conversion SVG document to another file format, for example, SVG to PNG:
You can download the complete examples and data files from GitHub. About downloading from GitHub and running examples, you find out from the How to Run the Examples section.
Converting a file to another format using the ConvertSVG() method is a sequence of operations among which document loading and saving:
1using Aspose.Svg;
2using System.IO;
3using Aspose.Svg.Saving;
4using Aspose.Svg.Converters; 1// Convert SVG to PNG using C#
2
3// Initialize an SVG document from a file
4using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "svg-to-png.svg")))
5{
6 // Create an instance of the ImageSaveOptions class
7 ImageSaveOptions pngSaveOptions = new ImageSaveOptions();
8
9 // Convert SVG to PNG
10 Converter.ConvertSVG(document, pngSaveOptions, Path.Combine(OutputDir, "svg-to-png.png"));
11}In the example, the
ImageSaveOptions() constructor initializes an instance of the ImageSaveOptions class that is passed to ConvertSVG() method. The
ConvertSVG(source, options, outputPath) method takes the required attributes and performs the conversion operation.
The figure illustrates the svg-to-png.png file.

To convert SVG to PNG using the RenderTo() method, take the following stages:
device) method.1using Aspose.Svg;
2using System.IO;
3using Aspose.Svg.Rendering.Image; 1// Convert SVG to PNG in C#
2
3// Open a source SVG document
4using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "light.svg")))
5{
6 // Initialize an instance of the ImageRenderingOptions class
7 ImageRenderingOptions pngOptions = new ImageRenderingOptions();
8
9 // Initialize an instance of the ImageDevice class and specify an output file to render
10 using (ImageDevice device = new ImageDevice(pngOptions, Path.Combine(OutputDir, "light_out.png")))
11 {
12 // Render SVG to PNG
13 document.RenderTo(device);
14 }
15}The
ImageDevice(options, file) constructor takes as arguments an instance of ImageRenderingOptions class, output file name and initializes a new instance of the
ImageDevice class. The
RenderTo(device) method converts and sends the current document to the output rendering device.
The figure illustrates the result of SVG to PNG conversion – light.png file.

You can customize the rendering process by specifying the page size, margins, background color, etc. For converting SVG to all mentioned above formats, from the
RenderingOptions class the following properties are inherited: BackgroundColor, Css, HorizontalResolution, PageSetup, and VerticalResolution.
Every output device PdfDevice, XpsDevice and ImageDevice has its own unique set of options implemented with classes PdfRenderingOptions, XpsRenderingOptions and ImageRenderingOptions respectively.
The options that are implementing with the PdfSaveOptions, XpsSaveOptions and ImageSaveOptions classes are inheriting from the PdfRenderingOptions, XpsRenderingOptions and ImageRenderingOptions classes respectively.
Aspose.SVG offers a free online SVG Converter for converting SVG files to a variety of popular formats. You can easily convert SVG to PDF, XPS, JPG, PNG, BMP, TIFF, GIF, WebP, and SVGZ. Just select a file, choose the format to convert, and you’re done. It’s fast and completely free!
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.