PDF has become one of the dominant file formats because of its cross-platform support. Due to the consistent layout of the PDF documents across heterogeneous devices, people use to prefer conversion of documents to PDF before sharing. However, in certain cases, PDFs need to be converted into some other file format. PDF to SVG conversion is widely adopted in various scenarios i.e. in order to embed the content of PDF documents in webpages. Therefore, in this article, you will learn how to convert PDF files to SVG using C#.
- C# PDF to SVG Converter API
- Convert PDF Files to SVG using C#
- Convert PDF to SVG with Additional Options
- Get a Free API License
C# PDF to SVG Converter API
Aspose.PDF for .NET is a PDF manipulation API that lets you create new and process existing PDF files from within .NET applications. In addition, the API also allows you to convert PDF files to SVG with high fidelity. You can either download the API’s DLL or install it via NuGet.
PM> Install-Package Aspose.Pdf
Convert PDF Files to SVG using C#
The following are the steps to convert a PDF file to SVG using Aspose.PDF for .NET.
- 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 using C#.
Convert PDF to SVG with Additional Options
Aspose.PDF for .NET also provides some additional options to customize the PDF to SVG conversion. 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 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#.
Get a Free API License
In case you want to try the API without evaluation limitations, you can get a free temporary license.
Conclusion
In this article, you have learned how to convert PDF files to SVG format using 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.