How to Convert PDF to SVG in C#

How to Convert PDF to SVG in C#

Recently, we published a blog post on how to convert Visio to SVG programmatically in C#. In this blog post, you will learn how to convert PDF to SVG in C# using this image generator API. PDF to SVG conversion is a lightweight process when you do it using this enterprise-level .NET library. Moreover, you can build more beyond a basic PDF to SVG converter programmatically. Before going ahead, make sure you have installed .NET on your local machine.

In this blog post, the following sections will be covered:

Image Generator - C# API Installation

Well, you may configure the library by downloading the DLL files or install it by running the following command in the NuGet package manager.

Install-Package Aspose.Words 

How to Convert PDF to SVG in C#

Now, you can build a PDF to SVG converter in C# by writing a couple of lines of source code in a .NET application.

The steps are:

  1. Create an instance of the Document class and load the source PDF file.
  2. Invoke the Save method to save the file in SVG format.

Copy & paste the following code into your main file to convert PDF to SVG in C#:

The output can be seen in the image below:

PDF to SVG converter

PDF to SVG Converter in C# - Advanced Options

Likewise, you can configure your API calls to meet your business requirements and you can specify certain options during PDF to SVG conversion.

Please follow the steps given below:

  1. Initialize an object of the Document class and load the source PDF file.
  2. Initializes a new instance of ImageSaveOptions class that can be used to save rendered images in the SVG format.
  3. Set the PageSet property to “0” to convert only the first page of a document.
  4. Change the image’s brightness by setting the value of the ImageBrightness property.
  5. Set the value of the ImageContrast property to modify the contrast of the image.
  6. Change the horizontal resolution by setting the value of the HorizontalResolution property.
  7. Call the Save method to save the SVG file.

Get a Free License

You can avail of a free temporary license to try the API without evaluation limitations.

Summing up

We are ending this blog post at this point. Hopefully, you have learned how to convert PDF to SVG in C# programmatically. In addition, you have gone through some advanced options for this image generator API. This guide will help you if you are willing to build a PDF to SVG converter for your business application. Finally, do not forget to visit the documentation to learn about other great methods.

Moreover, we suggest you follow our Getting Started guide.

Finally, conholdate.com is writing new blog posts. So, please stay in touch for regular updates.

Ask a question

You can let us know about your questions or queries on our forum.

FAQs

Can I convert a PDF to an SVG?

Create an instance of the Document class, load the source PDF file, and invoke the Save method to save the file in SVG format.

See Also