How to convert an ODT to PDF in C# .Net Framework

Converting between different document formats is one of life’s great struggles. Few relish the prospect of trying to parse a complex format, then jam it into the new format, accounting for all the subtleties and details. With that in mind, today’s post will be covering a quick and easy way of getting this done with almost no coding required. Essentially we will be using an API to perform the conversion.

First we must install our client package with this command for the console:

Install-Package Cloudmersive.APIClient.NET.DocumentAndDataConvert -Version 3.2.8

Following that will be our function call, as you see below here:

using System;using System.Diagnostics;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Api;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Client;using Cloudmersive.APIClient.NET.DocumentAndDataConvert.Model;namespace Example{public class ConvertDocumentOdtToPdfExample{public void main(){// Configure API key authorization: ApikeyConfiguration.Default.AddApiKey("Apikey", "YOUR_API_KEY");// Uncomment below to setup prefix (e.g. Bearer) for API key, if needed// Configuration.Default.AddApiKeyPrefix("Apikey", "Bearer");var apiInstance = new ConvertDocumentApi();var inputFile = new System.IO.Stream(); // System.IO.Stream | Input file to perform the operation on.try{// Convert ODT Text File to PDFbyte[] result = apiInstance.ConvertDocumentOdtToPdf(inputFile);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentOdtToPdf: " + e.Message );}}}}

You may not believe me, but that’s it. Seriously, that’s all you have to do.

There’s an API for that. Cloudmersive is a leader in Highly Scalable Cloud APIs.