This brief tutorial is designed to guide you on how to convert RTF to PDF using C# with the help of a set of steps to configure the environment and information of necessary classes to be used in this conversion. While writing converter for RTF to PDF C# runnable code is also demonstrated for complete understanding. You can customize the output PDF file converted from the RTF file in a variety of ways by using the PdfSaveOptions class object.
Steps to Convert RTF to PDF using C#
- Configure your project to add reference to Aspose.Words from the NuGet package manager
- Load the source RTF file from the disk into the Document class object
- Instantiate the PdfSaveOptions class object to configure the converted PDF from RTF
- Save the output PDF file using the desired PDF save options
By using C# RTF to PDF conversion is described here with the help of a sequence of operations required to perform this task like first the guidance is provided to configure the environment and then Document class reference is shared that can be used to load RTF as well as many other types of files supported by different word processor applications. In the end, we save the input RTF file as PDF along with the PdfSaveOptions class object that can be configured by setting the rendered color mode to GrayScale or Normal.
Code to Export RTF to PDF using C#
To convert RTF to PDF C# code is demonstrated here that uses PdfSaveOptions class to configure the output PDF file. You can set custom local time zone for date/time fields, set memory optimization settings to control the conversion of the large file, define the set of pages to be rendered, flag to use anti-aliasing for rendering, and many other configurations as well.
In this tutorial, we have learned how C# convert RTF to PDF using simple API calls. If you want to learn the conversion of HTML to PDF, refer to the article how to convert HTML to PDF using C# without interop.