How to Convert ODP Presentations to JPG Arrays using Node.js

Cloudmersive
2 min readNov 10, 2023

--

Each slide of our presentation document can be quickly represented as a lightweight JPG file through a simple & low-code API solution.

We can use the minimal code examples below to incorporate a quick & free-to-use ODP (Open Document Presentation) to JPG conversion API in any of our Node.js applications. We’ll get exactly one JPG image for each page/slide of our original presentation file, and we can control the output quality of our images by setting a special request parameter to an integer between 1 (highest compression) and 100 (lowest compression).

Our first step is to install the SDK. To do that, we can either run the following command:

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

Or we can add the following snippet to our package.json:

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

To go about authorizing our API requests, we can grab a free-tier API key by registering a free account on the Cloudmersive website. These allow a limit of 800 API calls per month with no additional commitment. Once we have our API key ready, we can then include the below code to call the function:

var CloudmersiveConvertApiClient = require('cloudmersive-convert-api-client');
var defaultClient = CloudmersiveConvertApiClient.ApiClient.instance;

// Configure API key authorization: Apikey
var Apikey = defaultClient.authentications['Apikey'];
Apikey.apiKey = 'YOUR API KEY';



var apiInstance = new CloudmersiveConvertApiClient.ConvertDocumentApi();

var inputFile = Buffer.from(fs.readFileSync("C:\\temp\\inputfile").buffer); // 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.convertDocumentOdpToJpg(inputFile, opts, callback);

Now we can easily make ODP to JPG conversions at will.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet