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 CorePDF

Validate Digital Signatures and the Integrity of PDF Documents in C# .NET

Learn how to validate digital signatures and the integrity of PDF documents using the PDF Validation component from TX Text Control in C# .NET. Ensure the authenticity and compliance of your…


ASP.NETASP.NET CorePDF

Validate PDF/UA Documents and Verify Electronic Signatures in C# .NET

The new TXTextControl.PDF.Validation NuGet package enables you to validate PDF/UA documents and verify digital signatures directly in your code without relying on third-party tools or external…


ASP.NETASP.NET CoreC#

How To Choose the Right C# PDF Generation Library: Developer Checklist

To make your choice easy, this guide provides a systematic evaluation framework for two library categories: basic and enterprise PDF libraries. It covers matching features to use cases, evaluating…


ASP.NETASP.NET CoreDigital Signatures

Why Digitally Signing your PDFs is the Only Reliable Way to Prevent Tampering

PDF documents are widely used for sharing information because of their fixed layout and cross-platform compatibility. However, it is crucial to ensure the integrity and authenticity of these…


ASP.NETAIASP.NET Core

Automating PDF/UA Accessibility with AI: Describing DOCX Documents Using TX…

This article shows how to use TX Text Control together with the OpenAI API to automatically add descriptive texts (alt text and labels) to images, links, and tables in a DOCX. The resulting…

Summarize this blog post with:

Share on this blog post on: