Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Last active September 3, 2025 10:14
Show Gist options
  • Select an option

  • Save aspose-com-gists/88d03d79c3bda8f63fe0ed49b235ce70 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/88d03d79c3bda8f63fe0ed49b235ce70 to your computer and use it in GitHub Desktop.
This Gist contains examples Aspose.SVG Merging SVG Files

Aspose.SVG for .NET – Merge SVG in C#

Ready-to-use C# examples from the How to Merge SVG Files article of the Aspose.SVG for .NET documentation, demonstrating how to combine and render multiple SVG documents into a single PDF document.

Topics Covered

  • Merge SVG Documents to PDF. Combine multiple SVG files and render them into a single PDF.
  • Render SVG to JPEG. Convert an SVG to JPEG using ImageDevice with ImageRenderingOptions.
  • Render SVG to PNG. Generate a PNG image from an SVG document.

How to Use These Examples

  1. Make sure you have the Aspose.SVG for .NET library installed.
  2. Find and copy the gist that corresponds to your specific task.
  3. Open and adjust the example files with your paths and file names.
  4. Run the code to merge SVGs to PDF or render SVGs to image formats.

Prerequisites

Resources & Support

Aspose.SVG for .NET Merging SVG Files
// Merge SVGs to PDF using C#
// Learn more: https://docs.aspose.com/svg/net/how-to-merge-svg-files/
// Initialize SVG documents from files to merge later
using (SVGDocument document1 = new SVGDocument(Path.Combine(DataDir, "circle.svg")))
using (SVGDocument document2 = new SVGDocument(Path.Combine(DataDir, "flower.svg")))
using (SVGDocument document3 = new SVGDocument(Path.Combine(DataDir, "lineto.svg")))
{
// Create an instance of SvgRenderer
using (SvgRenderer renderer = new SvgRenderer())
{
// Create an instance of PdfDevice
using (PdfDevice device = new PdfDevice(Path.Combine(OutputDir, "result.pdf")))
{
// Merge all SVG documents to PDF
renderer.Render(device, document1, document2, document3);
}
}
}
// Render SVG to JPG using C#
// Learn more: https://docs.aspose.com/svg/net/how-to-merge-svg-files/
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "owl.svg")))
{
using (SvgRenderer renderer = new SvgRenderer())
{
string outputDocumentPath = Path.Combine(OutputDir, "owl.jpg");
// Set the Format property
ImageRenderingOptions options = new ImageRenderingOptions(ImageFormat.Jpeg);
// Initialize an instance of the ImageDevice class
using (IDevice device = new ImageDevice(options, outputDocumentPath))
{
// Render SVG to JPG
renderer.Render(device, document);
}
}
}
// Render SVG to PNG using C#
// Learn more: https://docs.aspose.com/svg/net/how-to-merge-svg-files/
// Initialize an SVG document from a file
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "owl.svg")))
{
// Create an instance of SvgRenderer
using (SvgRenderer renderer = new SvgRenderer())
{
// Create an instance of ImageDevice
using (ImageDevice device = new ImageDevice(Path.Combine(OutputDir, "owl.png")))
{
// Render SVG to PNG
renderer.Render(device, document);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment