Find and replace an image

Hi,

May I ask how to find and replace an image…

I needed to replace the image with a text “Your Logo Here”.

Thanks
Joebet

Hi Joebet,

Thanks for your inquiry. Please use the following code to achieve this:

Document doc = new Document(MyDir + @"CoverPage.docx");
DrawingML dml = (DrawingML) doc.GetChildNodes(NodeType.DrawingML, true)[0];
dml.ImageData.SetImage(Image.FromFile(MyDir + "Aspose.Words.jpg"));
doc.Save(MyDir + @"out.docx");

I hope, this helps.

Best regards,

Thanks you for the fast support dude!