How to Convert DOCX to JPG in JavaScript

Cloudmersive
1 min readJun 1, 2021

--

Transforming a document into an image has the potential to be a time-consuming process, requiring hundreds of lines of code and a good deal of patience. To avoid the headache of a manual conversion, you can use the following API in JavaScript to convert a DOCX file into a JPG/JPEG image array; one for each page.

Let’s start by running this command to install jQuery:

bower install jquery

Then, we can call the conversion function by inputting the DOCX file into the below example code:

var form = new FormData();
form.append("inputFile", fileInput.files[0], "file");
var settings = {
"url": "https://api.cloudmersive.com/convert/docx/to/jpg",
"method": "POST",
"timeout": 0,
"headers": {
"quality": "<integer>",
"Content-Type": "multipart/form-data",
"Apikey": "YOUR-API-KEY-HERE"
},
"processData": false,
"mimeType": "multipart/form-data",
"contentType": false,
"data": form
};
$.ajax(settings).done(function (response) {
console.log(response);
});

Done! Visit the Cloudmersive website to retrieve your API key by registering for a free account; this will provide you with 800 calls/month across our entire library of APIs.

--

--

Cloudmersive
Cloudmersive

Written by Cloudmersive

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

No responses yet