Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

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

Select an option

Save aspose-com-gists/f36cd6a54b7a4c1b340f048d42349030 to your computer and use it in GitHub Desktop.
This Gist contains C# examples Aspose.SVG for .NET – Convert SVG Files

Aspose.SVG for .NET – Convert SVG to PDF, XPS, Images, and SVGZ in C#

This gist collection contains C# examples from the How to Convert SVG Files section of the Aspose.SVG for .NET documentation. Learn how to convert SVG documents to PDF, XPS, PNG, JPG, BMP, TIFF, GIF, and SVGZ, resize SVG output during rendering, and convert raster images to vector SVG.

What's Included?

  • Convert SVG to PDF and XPS – Convert SVG files to fixed-layout document formats with custom page settings.
  • Convert SVG to image formats – Export SVG to PNG, JPG, BMP, TIFF, and GIF with custom rendering options.
  • Use Converter.ConvertSVG() – Convert SVG documents with save options in a concise API call.
  • Use SVGDocument.RenderTo() – Render SVG documents through PDF, XPS, and image devices for greater control.
  • Resize SVG output – Fit, scale, contain, or crop SVG content during conversion.
  • Convert image to SVG – Convert raster images and image streams to vector SVG using ConvertImageToSVG().
  • Various conversion scenarios – Convert SVG from different sources (file, URL, string, stream) using default or custom save/render options.

About Aspose.SVG for .NET

Aspose.SVG for .NET is a powerful, on-premise library designed to create, manipulate, and convert SVG files. Its conversion API supports PDF, XPS, raster image formats, SVGZ, and image-to-SVG vectorization scenarios. The library helps developers control output format, page setup, rendering quality, background color, resolution, and sizing behavior programmatically.

How to Use These Examples

Each gist is a self-contained, executable example designed to help you quickly integrate SVG conversion functionalities into your .NET applications.

  1. Add Aspose.SVG for .NET Dependency – Ensure your .NET project has a reference to the Aspose.SVG for .NET library. You can easily install it via NuGet.
  2. Select an Example – Browse through the gists and choose the one that matches the conversion task you need to perform.
  3. Copy the Code – Copy the C# code directly from the selected gist.
  4. Execute – Paste the code into your project and run it to observe the powerful conversion capabilities.

You can download a free trial of Aspose.SVG for .NET and use a temporary license for unrestricted access.

Prerequisites

  • .NET Platforms: .NET Framework 4.6.1+, .NET Core 2.0+, or .NET 5+.
  • Supported OS: Windows, Linux, macOS.
  • Development environment such as Visual Studio.
  • Aspose.SVG for .NET installed via NuGet.

Resources

Aspose.SVG for .NET – How to Convert SVG Files
// Convert a raster JPG stream to vector SVG in C#
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-image/
// Prepare input and output
string imagePath = Path.Combine(DataDir, "tulip.jpg");
string outputFile = Path.Combine(OutputDir, "tulip.svg");
// Open the image as a FileStream
using (FileStream inputStream = new FileStream(imagePath, FileMode.Open, FileAccess.Read))
{
// Create vectorization configuration
ImageVectorizerConfiguration configuration = new ImageVectorizerConfiguration
{
PathBuilder = new BezierPathBuilder
{
TraceSmoother = new ImageTraceSmoother(1),
ErrorThreshold = 10,
MaxIterations = 1
},
ColorsLimit = 30,
LineWidth = 1
};
// Perform conversion from image stream to SVG
Converter.ConvertImageToSVG(configuration, inputStream, outputFile);
}
Console.WriteLine("Image converted to SVG successfully.");
// Convert a raster image to SVG in C# using ConvertImageToSVG()
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-image/
// Prepare paths for a source image file and output SVG file
string imageFile = Path.Combine(DataDir, "flower-pink.png");
string outputFile = Path.Combine(OutputDir, "flower-pink.svg");
// Create a configuration object
ImageVectorizerConfiguration configuration = new ImageVectorizerConfiguration
{
PathBuilder =
new BezierPathBuilder
{
TraceSmoother = new ImageTraceSmoother(3),
ErrorThreshold = 5,
MaxIterations = 5
},
ColorsLimit = 15,
LineWidth = 2
};
// Convert Image to SVG
Converter.ConvertImageToSVG(configuration, imageFile, outputFile);
// Convert SVG to BMP in C# using ImageDevice
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-image/
// Open a source SVG document
using (SVGDocument document = new SVGDocument(documentPath))
{
// Create ImageDevice, set image Format and specify an output file to render
using (IDevice device = new ImageDevice(new ImageRenderingOptions(ImageFormat.Bmp), Path.Combine(OutputDir, "conclusion_out.bmp")))
{
// Render SVG to BMP
document.RenderTo(device);
}
}
// Convert SVG to GIF in C# with custom settings
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-image/
// Initialize an SVG document from a file
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "owl.svg")))
{
// Initialize an instance of the ImageSaveOptions class and set the PageSetup property
ImageSaveOptions saveOptions = new ImageSaveOptions(ImageFormat.Gif);
saveOptions.PageSetup.AnyPage = new Page(new Drawing.Size(400, 600), new Margin(20, 20, 20, 20));
// Convert SVG to GIF
Converter.ConvertSVG(document, saveOptions, Path.Combine(OutputDir, "owl.gif"));
}
// Convert SVG to JPG in C# using ImageSaveOptions
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-image/
// Initialize an SVG document from a file
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "owl-edited.svg")))
{
// Initialize ImageSaveOptions
ImageSaveOptions saveOptions = new ImageSaveOptions(ImageFormat.Jpeg);
// Convert SVG to JPG
Converter.ConvertSVG(document, saveOptions, Path.Combine(OutputDir, "owl-edited.jpg"));
}
// Render SVG to JPEG in C# with and without antialiasing
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-image/
// Initialize an SVG document from a file
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "owl.svg")))
{
// Set Format and UseAntialiasing for jpgOptions1
ImageRenderingOptions jpegOptions1 = new ImageRenderingOptions(ImageFormat.Jpeg);
jpegOptions1.UseAntialiasing = true;
// Set Format and UseAntialiasing for jpgOptions2
ImageRenderingOptions jpegOptions2 = new ImageRenderingOptions(ImageFormat.Jpeg);
jpegOptions2.UseAntialiasing = false;
// Initialize an instance of the ImageDevice class
using (IDevice device = new ImageDevice(jpegOptions1, Path.Combine(OutputDir, "owl_out1.jpg")))
{
// Render SVG to JPG
document.RenderTo(device);
}
using (IDevice device = new ImageDevice(jpegOptions2, Path.Combine(OutputDir, "owl_out2.jpg")))
{
document.RenderTo(device);
}
}
// Convert an SVG file to PDF in C# using ConvertSVG()
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-pdf/
// Initialize an SVG document from a file
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "lineto.svg")))
{
// Initialize an instance of the PdfSaveOptions class
PdfSaveOptions saveOptions = new PdfSaveOptions();
saveOptions.BackgroundColor = System.Drawing.Color.Gray;
// Convert SVG to PDF
Converter.ConvertSVG(document, saveOptions, Path.Combine(OutputDir, "lineto_out.pdf"));
}
// Render SVG to PDF in C# with custom page settings
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-pdf/
// Initialize an SVG document from a file
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "light.svg")))
{
// Initialize an instance of the PdfRenderingOptions class and set custom PageSetup and JpegQuality properties
PdfRenderingOptions pdfOptions = new PdfRenderingOptions();
pdfOptions.PageSetup.AnyPage = new Page(new Drawing.Size(500, 500), new Margin(10, 10, 10, 10));
pdfOptions.JpegQuality = 10;
// Initialize an instance of the PdfDevice class
using (IDevice device = new PdfDevice(pdfOptions, Path.Combine(OutputDir, "light_out.pdf")))
{
// Render SVG to PDF, send the document to the rendering device
document.RenderTo(device);
}
}
// Convert an SVG file to PNG in C# using ConvertSVG()
// Learn more: https://docs.aspose.com/svg/net/convert-svg/
// Initialize an SVG document from a file
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "svg-to-png.svg")))
{
// Create an instance of the ImageSaveOptions class
ImageSaveOptions pngSaveOptions = new ImageSaveOptions();
// Convert SVG to PNG
Converter.ConvertSVG(document, pngSaveOptions, Path.Combine(OutputDir, "svg-to-png.png"));
}
// Render an SVG document to PNG in C# using RenderTo()
// Learn more: https://docs.aspose.com/svg/net/convert-svg/
// Open a source SVG document
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "light.svg")))
{
// Initialize an instance of the ImageRenderingOptions class
ImageRenderingOptions pngOptions = new ImageRenderingOptions();
// Initialize an instance of the ImageDevice class and specify an output file to render
using (ImageDevice device = new ImageDevice(pngOptions, Path.Combine(OutputDir, "light_out.png")))
{
// Render SVG to PNG
document.RenderTo(device);
}
}
// Render SVG to PNG in C# using ImageDevice
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-image/
// Prepare a path to a source SVG file
string documentPath = Path.Combine(DataDir, "snowflake.svg");
// Initialize an SVG document from the file
using (SVGDocument document = new SVGDocument(documentPath))
{
// Create the ImageDevice, set image Format and specify an output file to render
using (IDevice device = new ImageDevice(new ImageRenderingOptions(), Path.Combine(OutputDir, "snowflake.png")))
{
// Render SVG to PNG
document.RenderTo(device);
}
}
// Convert SVG to PNG in C# with default rendering options
// Learn more: https://docs.aspose.com/svg/net/resize-document/
// Prepare path to a source SVG file
string documentPath = Path.Combine(DataDir, "rendering.svg");
// Prepare a path to save the converted file
string savePath = Path.Combine(OutputDir, "a4.png");
// Create an instance of the SVGDocument class
using SVGDocument document = new SVGDocument(documentPath);
// Initialize an ImageRenderingOptions object with default options
ImageRenderingOptions opt = new ImageRenderingOptions();
// Create an output rendering device and convert SVG
using ImageDevice device = new ImageDevice(opt, savePath);
document.RenderTo(device);
// Convert SVG to PNG in C# with a custom background color
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-image/
// Prepare SVG code and save it to a file
string code = "<svg xmlns='http://www.w3.org/2000/svg'>" +
"<circle cx='100' cy='150' r='50' stroke='#2F4F4F' stroke-width='4' fill='#FF7F50' />" +
"<circle cx='180' cy='200' r='60' stroke='#2F4F4F' stroke-width='4' fill='#008B8B' />" +
"</svg>";
File.WriteAllText("example.svg", code);
// Initialize an SVG document from the file
using (SVGDocument document = new SVGDocument("example.svg"))
{
// Initialize an instance of the ImageSaveOptions class and set the BackgroundColor property
ImageSaveOptions saveOptions = new ImageSaveOptions();
saveOptions.BackgroundColor = System.Drawing.Color.Gainsboro;
// Convert SVG to PNG
Converter.ConvertSVG(document, saveOptions, Path.Combine(OutputDir, "output.png"));
}
// Convert SVG to TIFF in C# with custom settings
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-image/
// Open a source SVG document
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "conclusion.svg")))
{
// Initialize an instance of the ImageRenderingOptions class and set the Format and Compression properties
ImageRenderingOptions tiffOptions = new ImageRenderingOptions(ImageFormat.Tiff);
tiffOptions.Compression = Compression.None;
// Initialize an instance of the ImageDevice class and specify an output file to render
using (IDevice device = new ImageDevice(tiffOptions, Path.Combine(OutputDir, "conclusion.tiff")))
{
// Render SVG to TIFF
document.RenderTo(device);
}
}
// Convert an SVG file to XPS in C# using ConvertSVG()
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-xps/
// Initialize an SVG document from a file
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "owl.svg")))
{
// Initialize an instance of the XpsSaveOptions class and set the BackgroundColor property
XpsSaveOptions saveOptions = new XpsSaveOptions();
saveOptions.BackgroundColor = System.Drawing.Color.Gray;
// Convert SVG to XPS
Converter.ConvertSVG(document, saveOptions, Path.Combine(OutputDir, "owl_out.xps"));
}
// Render SVG to XPS in C# with custom page settings
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-xps/
// Initialize an SVG document from a file
using (SVGDocument document = new SVGDocument(Path.Combine(DataDir, "light.svg")))
{
// Initialize an instance of the XpsRenderingOptions class and set custom PageSetup properties
XpsRenderingOptions xpsRenderingOptions = new XpsRenderingOptions();
xpsRenderingOptions.PageSetup.AnyPage = new Page(new Drawing.Size(500, 500), new Margin(10, 10, 10, 10));
// Initialize an instance of the XpsDevice class
using (IDevice device = new XpsDevice(xpsRenderingOptions, Path.Combine(OutputDir, "light_out.xps")))
{
// Render SVG to XPS and send the document to the rendering device
document.RenderTo(device);
}
}
// Convert SVGZ to PDF in C#
// Learn more: https://docs.aspose.com/svg/net/convert-svg/
using (var document = new SVGDocument(Path.Combine(DataDir, "aspose.svgz")))
{
Converter.ConvertSVG(document, new PdfSaveOptions(), Path.Combine(OutputDir, "aspose-output.pdf"));
}
// Convert SVGZ to PNG in C#
// Learn more: https://docs.aspose.com/svg/net/convert-svg/
using (var document = new SVGDocument(Path.Combine(DataDir, "aspose.svgz")))
{
Converter.ConvertSVG(document, new ImageSaveOptions(ImageFormat.Png), Path.Combine(OutputDir, "aspose-output.png"));
}
// Create SVG from scratch and convert it to JPEG in C#
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-image/
// Create a minimal SVG document with a single circle
using (var document = new SVGDocument())
{
var svgElement = document.RootElement as SVGSVGElement;
svgElement.SetAttribute("width", "400");
svgElement.SetAttribute("height", "400");
svgElement.SetAttribute("viewBox", "0 0 400 400");
// Create a simple circle
var circle = document.CreateElementNS("http://www.w3.org/2000/svg", "circle");
circle.SetAttribute("cx", "200");
circle.SetAttribute("cy", "200");
circle.SetAttribute("r", "100");
circle.SetAttribute("fill", "#1976d2");
circle.SetAttribute("stroke", "#0d47a1");
circle.SetAttribute("stroke-width", "5");
svgElement.AppendChild(circle);
// Save the SVG to a file
string svgPath = "simple_circle.svg";
document.Save(svgPath);
// Configure ImageSaveOptions for JPEG output with opaque background
var options = new ImageSaveOptions(ImageFormat.Jpeg);
options.BackgroundColor = System.Drawing.Color.WhiteSmoke; // JPEG doesn't support transparency
options.UseAntialiasing = true;
options.HorizontalResolution = 300;
options.VerticalResolution = 300;
// Convert SVG to JPEG
string jpegPath = Path.Combine(OutputDir, "output-circle.jpg");
Converter.ConvertSVG(svgPath, options, jpegPath);
}
// Create SVG from scratch and convert it to PDF in C#
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-pdf/
using (var document = new SVGDocument())
{
document.RootElement.SetAttribute("width", "800");
document.RootElement.SetAttribute("height", "600");
var defs = document.CreateElementNS("http://www.w3.org/2000/svg", "defs");
document.RootElement.AppendChild(defs);
var linearGradient = document.CreateElementNS("http://www.w3.org/2000/svg", "linearGradient");
linearGradient.SetAttribute("id", "gradient1");
linearGradient.SetAttribute("x1", "0%");
linearGradient.SetAttribute("y1", "0%");
linearGradient.SetAttribute("x2", "100%");
linearGradient.SetAttribute("y2", "100%");
defs.AppendChild(linearGradient);
var stop1 = document.CreateElementNS("http://www.w3.org/2000/svg", "stop");
stop1.SetAttribute("offset", "0%");
stop1.SetAttribute("stop-color", "#4CAF50");
linearGradient.AppendChild(stop1);
var stop2 = document.CreateElementNS("http://www.w3.org/2000/svg", "stop");
stop2.SetAttribute("offset", "100%");
stop2.SetAttribute("stop-color", "#2196F3");
linearGradient.AppendChild(stop2);
var group = document.CreateElementNS("http://www.w3.org/2000/svg", "g");
group.SetAttribute("transform", "translate(50, 50)");
document.RootElement.AppendChild(group);
var rect = document.CreateElementNS("http://www.w3.org/2000/svg", "rect");
rect.SetAttribute("x", "0");
rect.SetAttribute("y", "0");
rect.SetAttribute("width", "300");
rect.SetAttribute("height", "200");
rect.SetAttribute("fill", "url(#gradient1)");
rect.SetAttribute("rx", "10");
rect.SetAttribute("ry", "10");
group.AppendChild(rect);
for (int i = 0; i < 5; i++)
{
var line = document.CreateElementNS("http://www.w3.org/2000/svg", "line");
line.SetAttribute("x1", (30 + i * 45).ToString());
line.SetAttribute("y1", "35");
line.SetAttribute("x2", (70 + i * 45).ToString());
line.SetAttribute("y2", "165");
line.SetAttribute("stroke", "white");
line.SetAttribute("stroke-width", "3");
line.SetAttribute("opacity", "0.7");
group.AppendChild(line);
}
var circle = document.CreateElementNS("http://www.w3.org/2000/svg", "circle");
circle.SetAttribute("cx", "400");
circle.SetAttribute("cy", "300");
circle.SetAttribute("r", "80");
circle.SetAttribute("fill", "#ff9800");
circle.SetAttribute("stroke", "white");
circle.SetAttribute("stroke-width", "3");
document.RootElement.AppendChild(circle);
var path = document.CreateElementNS("http://www.w3.org/2000/svg", "path");
path.SetAttribute("d", "M 500 400 L 600 300 L 700 400 Z");
path.SetAttribute("fill", "#6a1b9a");
path.SetAttribute("stroke", "black");
path.SetAttribute("stroke-width", "2");
document.RootElement.AppendChild(path);
string svgPath = "complex_demo.svg";
document.Save(svgPath);
var pdfOptions = new PdfSaveOptions
{
HorizontalResolution = 300,
VerticalResolution = 300
};
pdfOptions.PageSetup.Sizing = Aspose.Svg.Rendering.SizingType.FitContent;
Converter.ConvertSVG(svgPath, pdfOptions, Path.Combine(OutputDir, "convert-svg-to-pdf.pdf"));
}
// Create SVG from scratch and convert it to PNG in C#
// Learn more: https://docs.aspose.com/svg/net/convert-svg-to-image/
using (var document = new SVGDocument())
{
var svg = document.RootElement;
svg.SetAttribute("width", "420");
svg.SetAttribute("height", "260");
svg.SetAttribute("viewBox", "0 0 420 260");
var background = document.CreateElementNS("http://www.w3.org/2000/svg", "rect");
background.SetAttribute("x", "0");
background.SetAttribute("y", "0");
background.SetAttribute("width", "420");
background.SetAttribute("height", "260");
background.SetAttribute("fill", "#f5f7fb");
svg.AppendChild(background);
var circle = document.CreateElementNS("http://www.w3.org/2000/svg", "circle");
circle.SetAttribute("cx", "150");
circle.SetAttribute("cy", "130");
circle.SetAttribute("r", "80");
circle.SetAttribute("fill", "#2196f3");
circle.SetAttribute("stroke", "#0d47a1");
circle.SetAttribute("stroke-width", "6");
svg.AppendChild(circle);
var rect = document.CreateElementNS("http://www.w3.org/2000/svg", "rect");
rect.SetAttribute("x", "235");
rect.SetAttribute("y", "70");
rect.SetAttribute("width", "130");
rect.SetAttribute("height", "120");
rect.SetAttribute("fill", "#ff9800");
rect.SetAttribute("rx", "14");
svg.AppendChild(rect);
document.Save("input.svg");
}
var options = new ImageSaveOptions();
options.BackgroundColor = System.Drawing.Color.White;
options.HorizontalResolution = 144;
options.VerticalResolution = 144;
Converter.ConvertSVG("input.svg", options, Path.Combine(OutputDir, "convert-svg-to-png.png"));
// Render SVG to JPG in C# with FitContent sizing
// Learn more: https://docs.aspose.com/svg/net/resize-document/
// Prepare path to a source SVG file
string documentPath = Path.Combine(DataDir, "rendering.svg");
// Prepare a path to save the converted file
string savePath = Path.Combine(OutputDir, "fitContent.jpg");
// Create an instance of SVGDocument class
using SVGDocument document = new SVGDocument(documentPath);
// Initialize an ImageRenderingOptions object with custom options. Use the FitContent flag
ImageRenderingOptions opt = new ImageRenderingOptions(ImageFormat.Jpeg);
opt.PageSetup.Sizing = SizingType.FitContent;
// Create an output rendering device and convert SVG
using ImageDevice device = new ImageDevice(opt, savePath);
document.RenderTo(device);
// Render SVG to PNG in C# using Contain sizing
// Learn more: https://docs.aspose.com/svg/net/resize-document/
// Prepare path to a source SVG file
string documentPath = Path.Combine(DataDir, "rendering.svg");
// Prepare a path to save the converted file
string savePath = Path.Combine(OutputDir, "using-contain.png");
// Initialize SVGDocument
using SVGDocument document = new SVGDocument(documentPath);
// Initialize an ImageRenderingOptions object with custom options. Use the Contain flag
ImageRenderingOptions opt = new ImageRenderingOptions();
opt.PageSetup.AnyPage = new Page(new Drawing.Size(2000, 2500));
opt.PageSetup.Sizing = SizingType.Contain;
// Create an output rendering device and convert SVG
using ImageDevice device = new ImageDevice(opt, savePath);
document.RenderTo(device);
// Render SVG to JPEG in C# using Crop sizing
// Learn more: https://docs.aspose.com/svg/net/resize-document/
// Prepare path to a source SVG file
string documentPath = Path.Combine(DataDir, "rendering.svg");
// Prepare a path to save the converted file
string savePath = Path.Combine(OutputDir, "using-crop.jpg");
// Initialize SVGDocument
using SVGDocument document = new SVGDocument(documentPath);
// Initialize an ImageRenderingOptions object with custom options. Use the Crop flag
ImageRenderingOptions opt = new ImageRenderingOptions(ImageFormat.Jpeg);
opt.PageSetup.AnyPage = new Page(new Drawing.Size(500, 1000));
opt.PageSetup.Sizing = SizingType.Crop;
// Create an output rendering device and convert SVG
using ImageDevice device = new ImageDevice(opt, savePath);
document.RenderTo(device);
// Render SVG to PNG in C# using ScaleContent sizing
// Learn more: https://docs.aspose.com/svg/net/resize-document/
// Prepare path to a source SVG file
string documentPath = Path.Combine(DataDir, "rendering.svg");
// Prepare a path to save the converted file
string savePath = Path.Combine(OutputDir, "scaleContent.png");
// Create an instance of the SVGDocument class
using SVGDocument document = new SVGDocument(documentPath);
// Initialize an ImageRenderingOptions object with custom options. Use the ScaleContent flag
ImageRenderingOptions opt = new ImageRenderingOptions();
opt.PageSetup.AnyPage = new Page(new Drawing.Size(1500, 3000));
opt.PageSetup.Sizing = SizingType.ScaleContent;
// Create an output rendering device and convert SVG
using ImageDevice device = new ImageDevice(opt, savePath);
document.RenderTo(device);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment