SVGCreator 1.1.0

dotnet add package SVGCreator --version 1.1.0
                    
NuGet\Install-Package SVGCreator -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SVGCreator" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SVGCreator" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="SVGCreator" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SVGCreator --version 1.1.0
                    
#r "nuget: SVGCreator, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SVGCreator@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SVGCreator&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=SVGCreator&version=1.1.0
                    
Install as a Cake Tool

SVGCreator

SVGCreator is a lightweight C# library for creating SVG documents programmatically. It allows you to define shapes, lines, curves, and text with a fluent API, then export the complete SVG as a string.

Features

  • Create SVG documents of any width and height.
  • Add circles, lines, curved lines, text and much more.
  • Use the builder pattern for easy and readable SVG creation.
  • Supports colors, stroke widths, fonts, and positioning.
  • Easily extendable with new shapes.

Github

https://github.com/Thekid2002/SVGCreator

Usage

using System.Drawing;
using SVGCreator;

class Program
{
    static void Main()
    {
        ISvgDocument svg = new SvgDocument()
            .SetWidth(500)
            .SetHeight(500)
            .AddCircle((250, 250), 100, Color.Red, Color.Black, 2)
            .AddLine((50, 50), (450, 450), Color.Blue, 3)
            .AddCurvedLine(new List<(int, int)>
            {
                (50, 250),
                (150, 350),
                (250, 250),
                (350, 150),
                (450, 250)
            }, Color.Green, 2)
            .AddText("Hello SVG", (200, 100), 24, "Arial", Color.Black, null, null);

        string svgContent = svg.ToString();

        // Save to file
        System.IO.File.WriteAllText("output.svg", svgContent);
    }
}

API Overview

The main interface is ISvgDocument, which SvgDocument implements. The inteface IShape can be implemented to create custom shapes and then added to the SVG document.

Shape Methods

Method Description
AddCircle((int x, int y) center, int radius, Color? fillColor, Color? strokeColor, int? strokeWidth, string? additionalAttributesString = null) Adds a circle to the SVG document.
AddLine((int x, int y) start, (int x, int y) end, Color strokeColor, int strokeWidth, string? additionalAttributesString = null) Adds a straight line to the SVG document.
AddCurvedLine(List<(int,int)> points, Color strokeColor, int strokeWidth, string? additionalAttributesString = null) Adds a curved line defined by multiple points (polyline/path).
AddText(string content, (int x, int y) center, int fontSize, string? fontFamily, int? rotation, Color? fillColor, Color? strokeColor, int? strokeWidth, string? additionalAttributesString = null) Adds text to the SVG document.
AddSquare((int x, int y) center, int sideLength, Color? fillColor, Color? strokeColor, int? strokeWidth, string? additionalAttributesString = null) Adds a square to the SVG document.
AddRectangle((int x, int y) center, int width, int height, Color? fillColor, Color? strokeColor, int? strokeWidth, string? additionalAttributesString = null) Adds a rectangle to the SVG document.
AddShape(IShape shape) Adds a custom shape implementing the IShape interface.

Notes

  • Colors use System.Drawing.Color. The library automatically converts them to SVG hex strings.
  • Text and curved lines are positioned using top-left or point lists.
  • The generated SVG can be saved directly to a .svg file and viewed in browsers or vector graphic editors.
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.0 209 10/27/2025
1.0.8 202 10/27/2025
1.0.7 190 10/27/2025
1.0.6 192 10/27/2025
1.0.5 115 10/25/2025
1.0.4 116 10/25/2025
1.0.3 108 10/25/2025
1.0.2 115 10/25/2025
1.0.1 145 10/24/2025
1.0.0 146 10/24/2025