Convert PDF to SVG (Scalable Vector Graphics) in C#, VB.NET

About SVG (Scalable Vector Graphics)

SVG (Scalable Vector Graphics) is an image file format for two-dimensional, XML based vector images developed by the World Wide Web Consortium (W3C). Comparing with other image file formats, SVG has many advantages such as supporting interactivity and animation, allowing users to search, index, script, and compress/enlarge images without losing quality and it can be created and edited with any text editor.

Convert PDF to SVG (Scalable Vector Graphics) using Spire.PDF

Very often, developers need to convert files like PDF to SVG file format. The following part shows how to accomplish this requirement using a powerful .NET PDF component - Spire.PDF. Below is the screenshot of the source PDF file:

Convert PDF to SVG (Scalable Vector Graphics) in C#, VB.NET

Detail steps:

Step 1: Create a C#/Vb.net project in visual studio, then add a reference to Spire.Pdf.dll and use the following namespace.

using Spire.Pdf;

Step 2: Instantiate an object of PdfDocument class and load the source PDF file.

PdfDocument document = new PdfDocument();
document.LoadFromFile("Test.pdf");

Step 3: Call SaveToFile(string filename, FileFormat fileFormat) method to save PDF file to SVG file format.

document.SaveToFile(@"E:\Program Files\Result.svg", FileFormat.SVG);

After running the code, we'll get the following result SVG file:

Convert PDF to SVG (Scalable Vector Graphics) in C#, VB.NET

Full code:

[C#]
using Spire.Pdf;

namespace Convert_PDF_to_SVG
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument document = new PdfDocument();
            document.LoadFromFile("Test.pdf");

            document.SaveToFile(@"E:\Program Files\Result.svg", FileFormat.SVG);
        }
    }
}
[VB.NET]
Imports Spire.Pdf

Namespace Convert_PDF_to_SVG
	Class Program
		Private Shared Sub Main(args As String())
			Dim document As New PdfDocument()
			document.LoadFromFile("Test.pdf")

			document.SaveToFile("E:\Program Files\Result.svg", FileFormat.SVG)
		End Sub
	End Class
End Namespace