RTF is a cross-platform rich text file format introduced by Microsoft. In addition to text, it can include extra information about font style, formatting, images, etc. There might be situations such as sharing the file over the internet where you do not want the file to be editable or want the file to have a fixed layout. In such cases, PDF format is your best bet. PDF is a cross-platform format that can be secured and made read-only. Furthermore, the PDF file looks the same wherever you open it. In this article, you will learn how to convert RTF files to PDF format using C++.
RTF to PDF C++ Conversion API
We will use the Aspose.Words for C++ API to convert RTF documents to PDF format. It is a native C++ library that allows you to generate, alter and convert Microsoft Word files. Furthermore, it also supports converting files to PDF format. You can either install the API through NuGet or download it directly from the Downloads section.
PM> Install-Package Aspose.Words.Cpp
C++ RTF to PDF Conversion
The following are the steps to convert RTF documents to PDF format.
- Load the RTF document using the Document(System::String fileName) constructor of the Document class.
- Save the RTF file as PDF using the Document->Save(System::String fileName, Aspose::Words::SaveFormat saveFormat) method.
The following is the code sample for converting RTF documents to PDF format.
Get a Free License
You can try the API without evaluation limitations by requesting a free temporary license.
In this article, you have learned how to convert RTF documents to PDF format programmatically using C++. In order to perform this conversion, we have used Aspose.Words for C++, which is a feature-rich API that lets you automate workflows related to MS Word. You can explore the API in detail by using the official documentation.