Looking for a quick and easy to implement solution for PDF to SVG conversion in C#? You are at the right place where you will find how to convert PDF files to SVG format with high speed, quality, and accuracy.
PDF has become one of the dominant file formats because of its cross-platform support. Due to the consistent layout of PDF documents across heterogeneous devices, people use to prefer the conversion of documents to PDF before sharing. PDF to SVG conversion is widely adopted in various scenarios i.e. to embed the content of PDF documents in webpages. So let’s see how to perform PDF to SVG conversion.
- C# .NET PDF to SVG Converter API
- Convert PDF Files to SVG in C#
- Convert PDF to SVG with Additional Options
C# PDF to SVG Conversion Library
To convert PDF files to SVG format, we will use Aspose.PDF for .NET. It is a PDF manipulation library that lets you create new and process existing PDF files from within .NET applications. In addition, the library allows you to convert PDF files to SVG with high fidelity.
You can either download the library’s DLL or install it via NuGet.
PM> Install-Package Aspose.PDF
Convert PDF to SVG in C#
The following are the steps to convert a PDF file to SVG in C#.
- Load the PDF document using Document class.
- Create an instance of SvgSaveOptions class.
- Save PDF as SVG using Document.Save(String, SvgSaveOptions) method.
The following code sample shows how to convert a PDF file to SVG in C#.
Customized PDF to SVG C# Conversion
Aspose.PDF for .NET also provides some additional options to customize the PDF to SVG conversion in C#. For this, the API provides SvgSaveOptions class that contains the following options.
- CompressOutputToZipArchive - Specifies whether the output will be created as one ZIP archive.
- CustomStrategyOfEmbeddedImagesSaving - Strategy for customized handling of referenced external image files.
- ScaleToPixels - Specifies whether to scale the output document from typographic points to pixels.
- TreatTargetFileNameAsDirectory - Defines whether to create a target directory with the same name as the requested output file.
- TryMergeAdjacentSameBackgroundImages - To avoid visible boundaries between parts of the same background images.
The following are the steps to customize PDF to SVG conversion using SvgSaveOptions class.
- Load the PDF document using Document class.
- Create an instance of SvgSaveOptions class.
- Set the desired option such as SaveOptions.CompressOutputToZipArchive.
- Save PDF as SVG using Document.Save(String, SvgSaveOptions) method.
The following code sample shows how to convert a PDF file to SVG with additional options using C#.
Free C# PDF to SVG Conversion
You can get a free temporary license and convert PDF files to SVG format without any limitations.
Conclusion
In this article, you have learned how to convert PDF files to SVG format in C#. Furthermore, the additional options to customize PDF to SVG conversion have been discussed with the code sample. You can explore more about the C# PDF API using documentation.