Convert PDF to SVG with Custom Width and Height in C#, VB.NET

We've have demonstrated how to convert PDF page to SVG file format in the previous post. This guidance shows you how we can specify the width and height of output file using the latest version of Spire.PDF with C# and VB.NET.

Step 1: Load a sample PDF document to PdfDocument instance.

PdfDocument document = new PdfDocument();
document.LoadFromFile("pdf-sample.pdf");

Step 2: Specify the output file size through ConvertOptions.SetPdfToSvgOptions() method.

document.ConvertOptions.SetPdfToSvgOptions(800f, 1200f);

Step 3: Save PDF to SVG file format.

document.SaveToFile("result.svg", FileFormat.SVG);

Output:

Convert PDF to SVG with Custom Width and Height in C#, VB.NET

Full Code:

[C#]
PdfDocument document = new PdfDocument();
document.LoadFromFile("pdf-sample.pdf");
document.ConvertOptions.SetPdfToSvgOptions(800f, 1200f);
document.SaveToFile("result.svg", FileFormat.SVG);
[VB.NET]
Dim document As New PdfDocument()
document.LoadFromFile("pdf-sample.pdf")
document.ConvertOptions.SetPdfToSvgOptions(800F, 1200F)
document.SaveToFile("result.svg", FileFormat.SVG)