This GitHub gist repository contains C# code samples that demonstrate how to use the powerful SVG Builder API. These examples are used in the SVG Builder – Advanced SVG Creation and Modification chapter of the official Aspose.SVG for .NET documentation and allow .NET developers to programmatically create, modify, and customize SVG documents with exceptional control and flexibility.
The snippets show how to build SVG from scratch, create shapes, paths, text, patterns, gradients, filters, clip paths, and CSS rules with fluent C# code.
Here you will find practical demonstrations of SVG creation and editing with the Builder API, including:
- SVG Element Creation – Create SVG structures from scratch, including basic shapes (circles, rectangles, paths), text, and groups through a fluent SVG Builder API.
- Working with Geometric Shapes – Create and modify basic SVG shapes, including circles, rectangles, and paths.
- Path Data Manipulation – Work directly with SVG path data for intricate shape creation and modification.
- Configuring SVG Styles – Define custom fonts (
@font-face) and apply CSS rules to text elements within an SVG document using the SVG Builder API. - Working with SVG Patterns – Set and apply various SVG patterns (
<pattern>) to fill shapes like circles, etc. - Applying CSS Rules – Define CSS rules for SVG elements (e.g., circle, text) using the Rule Builder API. Set properties like fill, stroke, stroke-width, font-family, and font-size directly within the C# code to style SVG components.
- Filters and Clip Paths – Add Gaussian blur, drop shadow filters, and clip paths with SVG Builder.
Each example is a standalone C# test designed to help you quickly understand and implement SVG Builder API features in .NET applications.
- Ensure that you have the Aspose.SVG for .NET library installed.
- Locate the example that corresponds to your specific task.
- Copy the C# code directly from the example.
- Adjust the file paths, input parameters, and output parameters as necessary.
- Run the code to create or modify SVG files.
- .NET Platforms: .NET Framework 4.6.1+, .NET Core 2.0+, or .NET 5+.
- Supported OS: Windows, Linux, macOS.
- Aspose.SVG for .NET installed via NuGet.
Aspose.SVG for .NET is an API for creating, parsing, editing, rendering, and converting SVG files in C# applications. Its SVG Builder API provides a fluent approach for building and modifying SVG documents with precise control over elements, styles, paths, paints, filters, and reusable graphics.