Merge SVG in C#

Merge SVG files together and save the result to popular formats including PDF, XPS, BMP, JPEG, PNG, GIF, and TIFF using C#

How to Merge SVG Using C#

There are a lot of reasons why you need to combine several SVGs into one document. To merge SVG files, we will use Aspose.SVG for .NET API which is a powerful and easy-to-use document manipulation API for the C# platform. Our C# library provides the SvgRenderer class for rendering and merging SVG documents. The Render() method gives you the ability to send multiple documents at once to the output rendering device and merge them.

C# example to combine SVG to PDF

A high-speed C# library allows .NET developers to merge SVG files and convert the combined result into many popular formats such as PDF, XPS, JPEG, PNG, BMP, GIF, and TIFF with high quality and efficiency. You can combine multiple SVG files into a single file of another format at the same time and improve performance for tasks such as resource management, optimizing the number of HTTP requests, reducing the loading time of web applications, etc. Documents merging can be done with a few lines of code:

Merge SVG to PDF – C#

// Initialize SVG documents from files to merge 
using (var document1 = new SVGDocument("document1.svg"))
using (var document2 = new SVGDocument("document2.svg"))
using (var document3 = new SVGDocument("document3.svg"))
    // Create an instance of SvgRenderer
    using var renderer = new Aspose.Svg.Rendering.SvgRenderer();
    // Create an instance of SvgRenderer
    using var device = new Aspose.Svg.Rendering.Pdf.PdfDevice("result.pdf");
    //Merge all SVG documents to PDF
    renderer.Render(device, document1, document2, document3);

In the C# example above, the output format is PDF, as indicated by the use of PdfDevice. If you want to change the output format, you will need to use a different device class that matches the desired format. For example, you can use ImageDevice for PNG, JPEG, BMP, GIF, or TIFF formats. Additionally, you will need to provide the appropriate file extension in the output file path.

SVG Merger in Documentation

Aspose.SVG for .NET library lets you create, edit, read, convert, and merge SVG files programmatically using C#. The Aspose.Svg.Rendering namespace implements easy access to convert and merge methods. In addition, it provides combining SVG files into popular formats, such as PDF, XPS, JPEG, PNG, BMP, TIFF, and GIF. Please visit the documentation chapter How to Merge SVG Files to learn more about SVG C# API merging features. Experience the power and flexibility of SVG merging by including Aspose.SVG in your C# projects today!

Installing Aspose.SVG for .NET library

Aspose.SVG for .NET is a cross-platform flexible library that is designed to provide a wide range of features for processing and rendering SVG documents. It seamlessly integrates into your .NET Apps to work with SVG files without installing any 3rd party software. Our SVG .NET API can be used with any .NET language, such as C#, VB.NET, ASP.NET, etc. It works equally well on any OS that can install Mono (.NET 4.0 Framework support) or use .NET core. This includes Windows, Linux, and macOS.

Installing Aspose.SVG for .NET through NuGet :

  1. Using the Package Manager Console.
  2. Using the NuGet Package Manager GUI.

For more details about C# library installation, please refer to Aspose.SVG Documentation .

Other Supported Mergers

You can combine SVG files into many other file formats including few listed below: