How to Create SVG in C#

This basic tutorial guides you on how to create SVG in C#. The steps and the code snippet demonstrate how using C# generate SVG image programmatically. We only need to make a few API calls with a couple of lines of code in .NET applications to accomplish the task.

Steps to Create SVG in C#

  1. Setup the project to install Aspose.SVG for .NET using the NuGet package manager
  2. Specify the SVG content as a string
  3. Create an instance of the SVGDocument class with the string
  4. Save the file as an SVG image

These steps describe how using C# draw SVG image file. You can update the SVG string as a whole, or alter the values of some parameters to create different SVG images as per the specific requirements.

Code to Create SVG in C#

The code snippet above demonstrates how using C# create SVG image in the .NET applications. Since the SVG is consistent with XML-based languages, it supports embedded content. Therefore, the API also enables you to embed HTML content by using the ‘foreignObject’ tag in the SVG string.

In this article, we have learned how to create an SVG image in C#. However, if you want to learn to convert SVG images to PDF files, please refer to the article on how to convert SVG to PDF in C#.

 English