Products Technologies Demo Docs Blog Support Company

Adding SVG Graphics to PDF Documents in C# .NET

In this article, we will explore how to add SVG graphics to PDF documents using C# .NET. We will use the TX Text Control .NET Server component to demonstrate the process of rendering SVG images in PDF files.

Adding SVG Graphics to PDF Documents in C# .NET

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);

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.

Stay in the loop!

Subscribe to the newsletter to receive the latest updates.

ASP.NET

Integrate document processing into your applications to create documents such as PDFs and MS Word documents, including client-side document editing, viewing, and electronic signatures.

ASP.NET Core
Angular
Blazor
JavaScript
React
  • Angular
  • Blazor
  • React
  • JavaScript
  • ASP.NET MVC, ASP.NET Core, and WebForms

Learn more Trial token Download trial

Related Posts

ASP.NETASP.NET CoreExtraction

Mining PDFs with Regex in C#: Practical Patterns, Tips, and Ideas

Mining PDFs with Regex in C# can be a powerful technique for extracting information from documents. This article explores practical patterns, tips, and ideas for effectively using regular…


ASP.NETASP.NET CoreForms

Streamline Data Collection with Embedded Forms in C# .NET

Discover how to enhance your C# .NET applications by embedding forms for data collection. This article explores the benefits of using Text Control's ASP.NET and ASP.NET Core components to create…


ASP.NETASP.NET CorePDF

Adding QR Codes to PDF Documents in C# .NET

This article explains how to add QR codes to PDF documents with the Text Control .NET Server component in C#. It provides the necessary steps and code snippets for effectively implementing this…


ASP.NETASP.NET CoreKeywords

Enhancing PDF Searchability in Large Repositories by Adding and Reading…

This article explores how to improve the searchability of PDF documents in large repositories by adding and reading keywords with C# .NET. This is especially helpful for applications that manage…


ASP.NETASP.NET CoreEncryption

How to Verify PDF Encryption Programmatically in C# .NET

This article explains how to programmatically verify the encryption of a PDF document using C# .NET. It provides the necessary steps and code examples to ensure the PDF is encrypted correctly,…