Add an Image to an Online Word Document in Node.JS

If you need to insert an image into your online Word document, this useful tool will transform what could be a complicated project into a painless task. Our Insert Image API can be used as a follow-up to our Begin Editing API, which creates an editing URL for your modification needs. This simple process allows you to place the image at the beginning/end of the document, or before/after an existing object using its path.

Image for post
Image for post

To open up our procedure, we will need to run this command to install the SDK:

npm install cloudmersive-convert-api-client –save

Or, add this snippet to the package.json:

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

Prior to calling the function, we will need the request configuration:

"InputDocumentFileBytes": "string",
"InputDocumentFileUrl": "string",
"InputImageFileBytes": "string",
"InputImageFileUrl": "string",
"ImageToAdd": {
"Path": "string",
"ImageName": "string",
"ImageId": 0,
"ImageDescription": "string",
"ImageWidth": 0,
"ImageHeight": 0,
"XOffset": 0,
"YOffset": 0,
"ImageDataEmbedId": "string",
"ImageDataContentType": "string",
"ImageInternalFileName": "string",
"ImageContentsURL": "string",
"InlineWithText": true
"InsertPlacement": "string",
"InsertPath": "string",
"WidthInEMUs": 0,
"HeightInEMUs": 0

Now, to resume the process, we will call the insert image function with the following code:

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

And that about wraps things up! The returned response will provide us with the updated editing URL. If you wish to perform further editing, you may continue on, or if you wish to close out and download your document, you can run our Finish Editing function.

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

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