Insert an Image into an Online Word Document in Java

In an effort to optimize your DOCX document editing procedure, we have created several APIs that can shorten your processing time and simplify your task. One such API is our Insert Image tool, which follows the Begin Editing function in the editing path.

To start things off, you can install the Maven SDK by adding a reference to the repository in pom.xml:


Then, add a reference to the dependency:


Now before we call our function, you will need the request configuration to input:

"InputFileBytes": "string",
"InputFileUrl": "string",
"ParagraphToInsert": {
"ParagraphIndex": 0,
"Path": "string",
"ContentRuns": [
"RunIndex": 0,
"Path": "string",
"TextItems": [
"TextIndex": 0,
"Path": "string",
"TextContent": "string"
"Bold": true,
"Italic": true,
"Underline": "string",
"FontFamily": "string",
"FontSize": "string"
"StyleID": "string"
"InsertPlacement": "string",
"InsertPath": "string"

After this, we are officially ready to call our Insert Image function:

// Import classes:
//import com.cloudmersive.client.invoker.ApiClient;
//import com.cloudmersive.client.invoker.ApiException;
//import com.cloudmersive.client.invoker.Configuration;
//import com.cloudmersive.client.invoker.auth.*;
//import com.cloudmersive.client.EditDocumentApi;
ApiClient defaultClient = Configuration.getDefaultApiClient();// Configure API key authorization: Apikey
ApiKeyAuth Apikey = (ApiKeyAuth) defaultClient.getAuthentication("Apikey");
Apikey.setApiKey("YOUR API KEY");
// Uncomment the following line to set a prefix for the API key, e.g. "Token" (defaults to null)
EditDocumentApi apiInstance = new EditDocumentApi();
InsertDocxInsertParagraphRequest reqConfig = new InsertDocxInsertParagraphRequest(); // InsertDocxInsertParagraphRequest | Document input request
try {
InsertDocxInsertParagraphResponse result = apiInstance.editDocumentDocxInsertParagraph(reqConfig);
} catch (ApiException e) {
System.err.println("Exception when calling EditDocumentApi#editDocumentDocxInsertParagraph");

To conclude the process, a result will be returned with your edited document URL; this can be used for continued modifications, or to wrap things up and download your document with the Finish Editing function. If you want to retrieve your personal API key, head to the Cloudmersive website to register for a free account and receive access to 800 calls/month across our library of APIs.

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