How to Convert ODT to PDF in C#

In this how-to article, we will discuss the complete workflow using one of the popular document conversion packages to convert ODT to PDF in C# and produce a sample working code for the C# ODT to PDF conversion application for demonstration. Additionally, we will guide you on how to customize the converted PDF document by defining various properties. Here are the main steps and a sample code snippet for converting the ODT file to PDF using C# language.

Steps to Convert ODT to PDF in C#

  1. Install GroupDocs.Conversion for .NET package from the NuGet to convert ODT to PDF
  2. Add a reference to the GroupDocs.Conversion namespace for converting from ODT to PDF format
  3. Create an instance of the Converter class for loading the input ODT file from the disk for transforming to PDF format
  4. Create and set convert options for customizing the converted PDF file
  5. Finally, call the Convert method to save ODT as PDF on the disk

To create the application for ODT to PDF conversion using C#, the above points help you to rapidly implement the functionality. The document conversion workflow is very simple and you can instantiate the process by setting up the required conversion package from the NuGet website and then including the essential namespaces. Once you are done with the first two steps, it’s time to load the input ODT file by using the Converter class and then initialize the PdfConvertOptions class for defining parameters to customize the converted PDF document. The last step enables you how to call the Convert method and store the resultant file.

Code to Convert ODT to PDF in C#

We have developed the above sample code to convert ODT file to PDF in C# using the workflow defined in the previous section. This is a working example and can be directly used in projects for performing the document transformation after installing the mentioned library and adjusting the file paths. Moreover, you are not required to install any other tool and can run this code on any of the popular operating systems including Windows, macOS, and Linux.

We have discussed the document transformation process for transforming ODT to PDF using C# and produced a sample code for it. Recently, we published an article to change Text File to JPG in C#, have a look at how to convert Text File to JPG using C# guide for more information.

 English