Convert PDF Page to SVG in C#/VB.NET

Spire.PDF allows us to convert a PDF document, a single page or a range of pages in a PDF document to SVG file format. We have introduced how to convert a PDF document to SVG, in this tutorial, we are going to demonstrate how to convert a PDF page to SVG.

Below is the source PDF file we used in this example:

Convert PDF Page to SVG in C#, VB.NET

Code snippets:

Step 1: Instantiate an object of PdfDocument class and load the PDF document.

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

Step 2: Convert the first page of the PDF document to SVG using the SaveToFile(string filename, int startIndex, int endIndex, FileFormat fileFormat) method.

doc.SaveToFile("Result.svg", 0, 0, FileFormat.SVG);

The resultant SVG file looks as follows:

Convert PDF Page to SVG in C#, VB.NET

Full code:

[C#]
using Spire.Pdf;

namespace PDF_Page_to_SVG
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile("Test.pdf");
            doc.SaveToFile("Result.svg", 0, 0, FileFormat.SVG);
        }
    }
}
[VB.NET]
Imports Spire.Pdf

Namespace PDF_Page_to_SVG
	Class Program
		Private Shared Sub Main(args As String())
			Dim doc As New PdfDocument()
			doc.LoadFromFile("Test.pdf")
			doc.SaveToFile("Result.svg", 0, 0, FileFormat.SVG)
		End Sub
	End Class
End Namespace