Need Merge docx and Images files

Dear team,

We need to merge image files with docx, please refer below input files and json and do need full

Input File : New Project.zip (564.2 KB)

@e503824 You can simply insert images into the main document. For example, you can use DocumentBuilder to achieve this:

String[] images = new String[] { "C:\\Temp\\Fig 4.jpeg", "C:\\Temp\\Figure1.jpg", "C:\\Temp\\Index.png" };
Document doc = new Document("C:\\Temp\\Title Page.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
// Move to document end.
builder.moveToDocumentEnd();
// Insert the images.
for (String imgPath : images)
{
    builder.writeln();
    builder.insertImage(imgPath);
}
// Save the result.
doc.save("C:\\Temp\\out.docx");

Dear team,

I have checked and I used below source code to test

public static void main(String[] args) throws Exception 
	{
		String[] images = new String[] { "C:\\Users\\e503824\\Desktop\\New Project\\Fig 4.jpeg", "C:\\Users\\e503824\\Desktop\\New Project\\Figure1.jpg", "C:\\Users\\e503824\\Desktop\\New Project\\Index.png" };
		Document doc = new Document("C:\\Users\\e503824\\Desktop\\New Project\\Title Page.docx");
		DocumentBuilder builder = new DocumentBuilder(doc);
		// Move to document end.
		builder.moveToDocumentEnd();
		// Insert the images.
		for (String imgPath : images)
		{
		    builder.writeln();
		    builder.insertImage(imgPath);
		}
		// Save the result.
		doc.save("C:\\Users\\e503824\\Desktop\\New Project\\OUT.docx");

  }
}

Its not getting merged

output : OUT.docx (66.4 KB)

Dear team,

Thanks now its working fine

1 Like

Dear team,

Now we need to merge multiple docx files and images please find below input files

Input File : New Project.zip (600.5 KB)

@e503824 Please see our documentation to learn how to insert or merge documents using Aspose.Words.