Add image at the end of word document

Hello Team,

I want to edit word document and want to add one image at the end of word document. Document can have multiple pages. Could you please share the code how I can achieve that?

Regards
Sudrashya

@Sudrashya you can use the following code to insert an image at the end:

Document doc = new Document("C:\\Temp\\input.docx");
DocumentBuilder builder = new DocumentBuilder(doc);

builder.MoveTo(doc.LastSection.Body.LastParagraph);

// Just to leave an empty line in between the image and the current last element
builder.Writeln();

builder.InsertImage("C:\\Temp\\image.png");

doc.Save("C:\\Temp\\output.docx");