Aspose.HTML for .NET not only offers processing of Hypertext Markup Language(HTML) files but also provides conversion among popular image file formats. You can leverage rich rendering and conversion features to render SVG files as PNG, JPG, or other widely used file formats. However, we will use this C# image processing library to convert SVG to PNG in C# programmatically. By the end of this guide, you will be able to develop an SVG to PNG converter easily. Moreover, we will implement the functionality by writing a code snippet to render SVG images to PNG in a .NET application. So, let’s make the code speak for itself.
- C# Image Processing Library Installation
- SVG to PNG Conversion in C# - Code Sample
- Online File Format Converter
C# Image Processing Library Installation
The installation of Aspose.HTML for .NET is quite easy, you can install it by downloading the DLL file or you can run the following command into NuGet Package Manager to install this C# image processing library:
PM> Install-Package Aspose.Html
SVG to PNG Conversion in C# - Code Sample
Before heading to the code sample, please make sure you have a source SVG file. Now, follow the following steps:
- Create an instance of the SVGDocument class to load the source SVG file.
- Instantiate an object of the SvgRenderer class.
- Initializes a new instance of the ImageDevice class.
- Invoke the Render method to render SVG as PNG.
Next, you can see the code snippet written below that is used to convert SVG to PNG in C# programmatically:
The above code snippet will render SVG to PNG and save the file onto the disk. As, you can see the output of the above code sample in the image below:
Online File Format Converter
Like programmatic solutions, Aspose.HTML for .NET has exposed an online tool that is equipped with a wide range of functions such as conversion, rendering merging, and more. There is no subscription or account creation required to use this free tool.
SVG to PNG Converter - Get a Free License
Now, you can avail a free temporary license to try this C# Image processing library without evaluation limitations.
Summing up
This is the end of this blog post. We will come again with another interesting topic on Aspose APIs. In this article, we learned how to convert SVG to PNG in C# using this C# image processing library. This blog post will help you in building an SVG to PNG conversion module for a business application. So, please visit this documentation, API references, and the GitHub repo to learn more about Aspose.HTML for .NET.
Ask a question
You can let us know about your questions or queries on our forum.
Frequently Asked Questions – FAQs
How to convert SVG to PNG programmatically?
Please visit this link to learn how to achieve SVG to PNG conversion in C#.
How to change SVG code to image?
Aspose.HTML for .NET offers conversion and rendering options. You can render SVG as PNG using this C# image processing library.