IronPDF How-Tos SVG Graphics Convert SVG to PDF in C# ByChaknith Bin January 25, 2023 Updated June 22, 2025 Share: IronPDF has extensive support for rendering SVG graphics into PDF documents via the "HTML to PDF" methodology.Please note that it is important to set the width and/or height style attribute of the img element when embedding an SVG - otherwise, it may collapse to zero size and not appear in the rendered PDF. View the IronPDF YouTube Playlist Get started with IronPDF Start using IronPDF in your project today with a free trial. First Step: Start for Free How to Convert SVG to PDF in C# Install IronPDF Library for SVG to PDF Conversion Use img tag in HTML to import SVG image Utilize different rendering methods in IronPDF to generate PDF Save the PDF file containing SVG image with SaveAs method Check the PDF in specified location Render SVG to PDF Example Many browsers are tolerant of SVGs having no size; however, our rendering engine is sensitive to this. :path=/static-assets/pdf/content-code-examples/how-to/SVGs-render.cs using IronPdf; // Define the HTML content to be included in the PDF. In this case, it's an image with a specified width. string html = "<img src='https://ironsoftware.com/img/svgs/new-banner-svg.svg' style='width:100px'>"; // Create a new instance of ChromePdfRenderer, which is used to convert HTML to PDF. ChromePdfRenderer renderer = new ChromePdfRenderer(); // Set rendering options to ensure any dynamic content, such as JavaScript-rendered elements, has time to load. // Here, we set a render delay of 1000 milliseconds (1 second) to allow dynamic content to completely load. renderer.RenderingOptions.RenderDelay = 1000; // Render the HTML content to a PDF document. PdfDocument pdf = renderer.RenderHtmlAsPdf(html); // Save the generated PDF document to a file named "svgToPdf.pdf" in the current directory. pdf.SaveAs("svgToPdf.pdf"); Imports IronPdf ' Define the HTML content to be included in the PDF. In this case, it's an image with a specified width. Private html As String = "<img src='https://ironsoftware.com/img/svgs/new-banner-svg.svg' style='width:100px'>" ' Create a new instance of ChromePdfRenderer, which is used to convert HTML to PDF. Private renderer As New ChromePdfRenderer() ' Set rendering options to ensure any dynamic content, such as JavaScript-rendered elements, has time to load. ' Here, we set a render delay of 1000 milliseconds (1 second) to allow dynamic content to completely load. renderer.RenderingOptions.RenderDelay = 1000 ' Render the HTML content to a PDF document. Dim pdf As PdfDocument = renderer.RenderHtmlAsPdf(html) ' Save the generated PDF document to a file named "svgToPdf.pdf" in the current directory. pdf.SaveAs("svgToPdf.pdf") $vbLabelText $csharpLabel Output PDF Additionally, or alternatively, an SVG node may have an explicit width and height attribute assigned. Please also see examples of SVG styling on CodePen. Frequently Asked Questions What is this library used for rendering SVG graphics into PDF documents? IronPDF is a library that supports rendering SVG graphics into PDF documents using the 'HTML to PDF' methodology. How do I install the library for SVG to PDF conversion? You can install IronPDF for SVG to PDF conversion by downloading it from the NuGet package repository. Why do SVG images need width and height attributes? SVG images need width and height attributes to prevent them from collapsing to zero size in the rendered PDF. Can I use SVG images without explicit size attributes? While many browsers can handle SVGs without size attributes, IronPDF's rendering engine requires explicit width and height attributes. How do I convert SVG to PDF in C#? To convert SVG to PDF using IronPDF in C#, embed the SVG in an HTML tag with specified width and height, render the HTML to PDF with IronPDF, and save the resulting PDF document. What method is used to save the PDF file in the library? The 'SaveAs' method is used to save the PDF file in IronPDF. Can I see examples of SVG styling? Yes, examples of SVG styling can be seen on CodePen as referenced in the webpage. What programming language is used in the provided example? The provided example for converting SVG to PDF uses C#. Is there a trial version available for the library? Yes, a trial version of IronPDF is available for download from the NuGet package repository. Chaknith Bin Chat with engineering team now Software Engineer Chaknith works on IronXL and IronBarcode. He has deep expertise in C# and .NET, helping improve the software and support customers. His insights from user interactions contribute to better products, documentation, and overall experience. Ready to Get Started? Free NuGet Download Total downloads: 14,143,061 View Licenses