News Category

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

2017-10-24 07:04:26 Written by  support iceblue
Rate this item
(0 votes)

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#]
using Spire.Pdf;

namespace ConvertPDFtoSVG
{
    class Program
    {
        static void Main(string[] args)
        {
            PdfDocument document = new PdfDocument();
            document.LoadFromFile("pdf-sample.pdf");
            document.ConvertOptions.SetPdfToSvgOptions(800f, 1200f);
            document.SaveToFile("result.svg", FileFormat.SVG);
        }
    }
}
[VB.NET]
Imports Spire.Pdf

Namespace ConvertPDFtoSVG
	Class Program
		Private Shared Sub Main(args As String())
			Dim document As New PdfDocument()
document.LoadFromFile("pdf-sample.pdf")
document.ConvertOptions.SetPdfToSvgOptions(800F, 1200F)
document.SaveToFile("result.svg", FileFormat.SVG)
		End Sub
	End Class
End Namespace

Additional Info

  • tutorial_title: Convert PDF to SVG with Custom Width and Height
Last modified on Sunday, 26 September 2021 01:31