PDF is a widely used document format for exchanging documents between individuals and different organizations. It is a standard document format, but sometimes it is not the ideal format for the situation. Nowadays, a lot of people are consuming content on their mobile devices such as smartphones or tablets. In such cases, SVG is a good alternative. SVG can be scaled to different screen sizes without losing quality and is the most used format for websites. Webpages can also use CSS styling to display SVG content. For this purpose, you will need to convert the PDF files to SVG. In this article, you will learn how to convert PDF files to SVG format using C++.
- C++ PDF to SVG Converter API – Free Download
- PDF to SVG C++ Conversion
- Convert PDF to SVG with Additional Options
- Get a Free License
C++ PDF to SVG Converter API – Free Download
Aspose.PDF for C++ API provides a lot of features for working with PDF files. The API allows you to create, read, convert, and manipulate PDF documents without using Adobe Acrobat. To convert PDF files to SVG, firstly, you need to download the API. Begin by downloading the API for free from the official website or by using the NuGet package.
PDF to SVG C++ Conversion
The following are the steps that you need to follow for converting PDF documents to SVG format:
- Firstly, use the Document class to load the PDF file.
- Create an object of the SvgSaveOptions class.
- Lastly, save the PDF as SVG by using the Document->Save(System::String outputFileName, System::SharedPtr options) method.
The following code snippet shows converting PDF to SVG using C++.
Convert PDF to SVG with Additional Options
The SvgSaveOptions class provides additional options to customize the PDF to SVG conversion. The following are the options provided by the SvgSaveOptions class.
- CompressOutputToZipArchive: Use this option to create one zip-archive output file.
- CustomStrategyOfEmbeddedImagesSaving: Use this option to specify the custom strategy for embedding external images to SVG. That strategy must process the resources and return a string URI of the saved resource.
- ScaleToPixels: This option specifies whether to scale the output from typographic points to pixels.
- TreatTargetFileNameAsDirectory: Set this option to true to save the output file in the directory with the same name as the output file.
You can follow the steps given below to convert PDF to SVG with additional options:
- Start by loading the PDF file by using the Document class.
- Create an instance of the SvgSaveOptions class.
- Set the desired option of the SvgSaveOptions class, such as TreatTargetFileNameAsDirectory.
- Finally, save the PDF as SVG with the Document->Save(System::String outputFileName, System::SharedPtr options) method.
The following code snippet demonstrates converting PDF to SVG with additional options.
Get a Free License
You can try the API without evaluation limitations by requesting a free temporary license.
Conclusion
In this article, you have learned how to convert PDF to SVG directly or by providing additional options to customize the conversion. Additionally, you can explore the Aspose.PDF for C++ API in detail by using the official documentation.