Document workflows increasingly rely on high-quality visuals, ranging from logos and icons to technical diagrams and infographics. Scalable Vector Graphics (SVG) are the preferred format for achieving sharp, scalable graphics in any output format over traditional raster images.

In this post, we will explore how to add SVG graphics to documents using TX Text Control and export them to PDF. We'll also examine the advantages of embedding vector graphics and how they're handled in PDF generation.

Why SVG?

SVG stands for Scalable Vector Graphics, a widely supported, XML-based vector image format. Unlike raster images, such as PNGs or JPEGs, SVGs are composed of paths, shapes, and text descriptions, rather than pixels. This allows them to scale without losing quality, making them ideal for high-DPI screens and print output.

Key advantages of using SVGs:

  • Resolution-independent: Perfectly crisp on screens and in print, no matter the zoom level.
  • Small file sizes: Perfectly crisp on screens and in print, no matter the zoom level.
  • Editability: Easily manipulated in design tools and programmatically adjusted.
  • Consistent rendering: Ensures the same quality across platforms and devices.

Adding SVGs in TX Text Control

TX Text Control allows you to insert SVG images directly into documents via API. Once added, the images behave like regular images and can be resized, positioned, anchored, or wrapped with text.

Learn More

This article shows how to create professional PDF and PDF/A documents using ASP.NET Core C# on Linux. TX Text Control enables the creation of pixel-perfect PDF documents on any Linux environment that supports .NET, including Debian, Ubuntu, and Azure App Services.

How to Create PDF Documents with TX Text Control using C# .NET on Linux

The following is an example of code to load an SVG from a file:

using TXTextControl;
using var tx = new ServerTextControl();
tx.Create();
var svgImage = new Image {
FileName = "tx_logo.svg"
};
tx.Images.Add(svgImage, -1);
tx.Save("results.pdf", StreamType.AdobePDF);
view raw test.cs hosted with ❤ by GitHub

The following screenshot shows how the crisp SVG image is rendered in the PDF document.

Adding SVG to PDF

Exporting to PDF: How Vector Graphics Are Embedded

When exporting a document with embedded SVGs to a PDF, TX Text Control performs an internal vector conversion. Rather than rasterizing the SVG to a bitmap, the image is translated into native PDF drawing commands.

This ensures that the final PDF file's output is vector-based, maintaining resolution independence and compact size.

In PDF terminology, the SVG becomes part of the page's content stream. This leverages the PDF's built-in graphics model, which is based on PostScript, to preserve the original vector design's full fidelity.

When Should You Use SVGs?

Consider using SVGs in your document generation pipeline if you are looking to:

  • You include company logos, certifications, or product icons
  • You output to PDF for printing or long-term archiving.
  • You need sharp graphics across different page sizes.
  • You want to ensure consistent rendering across devices and platforms.

Conclusion

SVG graphics are a powerful tool for improving the visual quality of documents, particularly PDFs. Their resolution independence, small file size, and ease of editing make them ideal for modern document workflows.

Leveraging TX Text Control's support for SVGs ensures that your documents maintain their visual integrity and professionalism when viewed on-screen or in print.