Text to Vector in C#

Vectorize text in SVG documents and save it as vector graphics

Convert Text to Vector Paths

Text vectorization is the process of converting embedded typography into vector paths (<path>) and geometric shapes. This conversion is highly beneficial because it makes your SVG documents entirely independent of system fonts. By replacing text tags with vector outlines, you ensure that your design always displays exactly as intended, regardless of the user’s operating system or installed fonts. Once vectorized, the text becomes a pure vector drawing that scales perfectly without losing quality.

The Aspose.SVG for .NET API makes this process incredibly simple, providing you with high-speed C# methods to automate text-to-path conversion in your SVG documents.


C# code example to vectorize text in an SVG document

When vectorizing SVG text, the API calculates the boundaries of your active fonts and replaces them with standard graphics elements. Aspose.SVG for .NET handles this conversion seamlessly during the saving process. To enable it, simply set the VectorizeText property of the SVGSaveOptions class to true. This allows you to vectorize text with just a few lines of C# code:


Convert text to vector – C#

// Load an SVG document from a file
SVGDocument document = new SVGDocument(Path.Combine(DataDir, "text.svg"));
// Create a Save Options object 
SVGSaveOptions saveOptions = new SVGSaveOptions
{
    VectorizeText = true
};
// Save the SVG document with specified saveOptions
document.Save(Path.Combine(OutputDir, "text_vectorized.svg"), saveOptions);



Steps to vectorize SVG text in C#

You can easily set up a text-to-path generation workflow with these three steps:

  1. Load your existing SVG document by passing the file path to one of the SVGDocument() constructors.
  2. Create an instance of the SVGSaveOptions() class. Set the VectorizeText property to true to instruct the parser to replace all text nodes with vector paths.
  3. Call the Save() method, providing both your output file path and the configured save options object.

For a deeper understanding of how vectorization shapes work and how to handle advanced security configurations, please visit the Vectorization – Basic Overview documentation. We also highly recommend reviewing the Text Vectorization & Text Security article for best practices when handling proprietary font files on public servers.


What is SVG text?

The <text> element is used to define a text. SVG text content elements are rendered like other graphics elements. Thus, coordinate system transformations, painting, clipping, and masking features apply to ‘text’ elements similarly to shapes such as paths and rectangles. SVG text content elements have font-family, font-size, font-weight, end other attributes in which you can set font properties. The vectorized text has no font and glyph concepts, only paths, shapes, etc.


Online Text Vectorizer

If you want to quickly test text vectorization without writing code, try our free Text to Vector web app. It processes your SVG documents immediately, safely converting font architectures into clean vector paths that you can download directly from your browser.



Get Started with Aspose.SVG for .NET API

If you are interested in developing scalable vector graphics and their application, install our flexible, high-speed Aspose.SVG for .NET API with a powerful set of interfaces for C# and other .NET programming languages.
Install from command line as nuget install Aspose.SVG or via Package Manager Console of Visual Studio with Install-Package Aspose.SVG. Alternatively, get the offline MSI installer or DLLs in a ZIP file from downloads. Aspose.SVG for .NET API is a standalone library and does not depend on any software for SVG document processing.
For more details about C# library installation and system requirements, please refer to Aspose.SVG Documentation.



Other Supported Vectorizers