How to Convert ODS to JPG in Node.JS

Cloudmersive
2 min readJun 29, 2020

--

File conversion is a huge bummer, isn’t it? Each format has so many specific nuances and trying to code around these can quickly eat up an afternoon. There is a much easier method to accomplish this that will not waste any of your time at all. I’m going to demonstrate for you how to use an API to solve this problem once and for all.

Let’s begin with installation.

"dependencies": {
"cloudmersive-convert-api-client": "^2.4.8"
}

Next comes our API function call:

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 opts = {'quality': 56 // Number | Optional; Set the JPEG quality level; lowest quality is 1 (highest compression), highest quality (lowest compression) is 100; recommended value is 75. Default value is 75.};var callback = function(error, data, response) {if (error) {console.error(error);} else {console.log('API called successfully. Returned data: ' + data);}};apiInstance.convertDocumentOdsToJpg(inputFile, opts, callback);

The API is going to do all the hard work for us, returning our converted array of JPGs as raw byte arrays for maximum convenience. Easy.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet