Sign in

How to convert an ODT to PDF in Node.JS

Not everyone uses ODT for their documents so being able to convert them to PDFs is useful for many. If you are having trouble with your conversion, we can offer you the solution. Our Cloudmersive API does all the work for you, so that all you have to do is sit back and run the function.

Let’s start with installing the Cloudmersive API client using NPM install:

npm install cloudmersive-convert-api-client --save

Awesome, next step, you just have to copy the code below and run it:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;// Configure API key authorization: Apikeyvar Apikey = defaultClient.authentications['Apikey'];Apikey.apiKey = 'YOUR API KEY';// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)//Apikey.apiKeyPrefix = 'Token';var apiInstance = new CloudmersiveConvertApiClient.ConvertDocumentApi();var inputFile = "/path/to/file"; // File | Input file to perform the operation on.var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.convertDocumentOdtToPdf(inputFile, callback);

Alright, you should be all set. Now that the Cloudmersive API has run it’s code, you can finally relax knowing that your ODT has been successfully converted to a PDF.

Image for post
Image for post
Whoo! Don’t have to worry about ODT conversion any more!

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