Add Image in Word Document with NET REST API

The guide explains how to add image in Word document with NET REST API. You will learn the process to automatically add image to Word document online with C# Low Code API using the .NET cloud SDK. We will discuss various properties to customize the image before adding it to the document.

Prerequisite

Steps to Add a Picture to Word Document with C# REST API

  1. Initialize the WordsApi object with client ID/secret to add images
  2. Initialize the InsertDrawingObjectOnlineRequest object with source Word file bytes and output file name
  3. Create the DrawingObjectInsert object and set the characteristics of the image
  4. Set the target image in the request object
  5. Invoke the InsertDrawingObjectOnline method to insert an image in the Word document
  6. Save the output Word file with the image using the Document.TryGetValue() from the task result

The above steps define the process to add picture to Word document with NET REST API. Instantiate the process by creating the InsertDrawingObjectOnlineRequest object and setting the input Word file, name of output Word file, image size, position, and image file name. Finally, call the InsertDrawingObjectOnline method to add the image.

Code to Add Photo to Word Document with C# REST API

Use this sample code to add multiple photos to Word document with C# REST API. You can set the image margin, page number, column, wrap type, height, width, etc. You have the option to set the password, encryption password, revision author, and date time.

In this topic, we have learned to insert an image in a Word file. To add a watermark in the Word file, refer to the following article: Add a watermark in Word with NET REST API.

 English