How to Add Image in DOCX using C++

In this example, we will learn how to add image in DOCX using C++. Inserting images inside word document using C++ is one of commonly inquired requirement by developers. Adding image to DOC using C++ can be achieved using simple API calls.

Steps to Add Image in DOCX using C++

  1. Download and install latest Aspose.Words.Cpp NuGet package
  2. Add a reference to Aspose::Words namespace
  3. Instantiate Document Class object to load DOCX for adding image
  4. Instantiate DocumentBuilder class to work with content inside DOCX
  5. Use imageWriter method to load and add JPEG image inside document
  6. Save the DOCX with Image in C++ by using Save method

In the following example, you can easily add JPEG image to DOCX in C++ by using few API calls and having no external dependence on MS Word. The API allow you to add JPEG, PNG, GIF or EMF images inside Word document.

Code to Add Image in DOCX using C++

Earlier, we looked in to How to Convert Word Document to Images using C++. Whereas in this topic we have learnt how insert image to Word document using C++.

 English