How to convert ODS to PDF in C# .Net Framework

Trying to set up conversion between ODS and PDF is a great way to get some early gray hairs, a fact which I can attest to personally. But fret not, I come to you today bearing hope. By the end of this post, you will have an easy and reliable method that you can use to convert between document types in real time.

First up, we have our client package installation. Paste this command into NuGet’s console:

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

Following that, all we have to do is call our ODS to PDF conversion function using an API instance, as you see demonstrated below:

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 ConvertDocumentOdsToPdfExample{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 ODS Spreadsheet to PDFbyte[] result = apiInstance.ConvertDocumentOdsToPdf(inputFile);Debug.WriteLine(result);}catch (Exception e){Debug.Print("Exception when calling ConvertDocumentApi.ConvertDocumentOdsToPdf: " + e.Message );}}}}


Image for post
Image for post

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store