Convert SVG to PDF in C#
IronPDF has extensive support for rending 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.
How to Convert SVG to PDF in C#
- Install C# library to convert SVG to PDF
- Use
img
tag in HTML to import SVG image - Utilize different renderering methods in IronPDF to generate PDF
- Save the PDF file containing SVG image with
SaveAs
method - Check the PDF in specified location
Many browsers are tolerant of SVGs having no size, however our rendering engine is sensitive to this.
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/91525/potofgold.svg" style="width:100px"\>
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/91525/potofgold.svg" style="width:100px"\>
Additionally or alternatively an SVG node may have an explicit width and height attribute assigned.
Please also see these excellent SVG styling examples on CodePen: