Replace images in document?

Hi. I’m trying the evaluation and have a little problem I would like to solve before sending you the cash for an OEM license.

I have a document that i try to use as a base to generate reports on the fly from a .net application. I figured it would be easyier to get the look i want in word and simply read it with aspose, clone it, replace the relevant texts (for instans [name] or [email]) and then save it again. Works like a charm.

Only problem is i have a few images i would also like to replace and i havn’t figured out how to do that. So… is this possible?


Thanks for your inquiry. Of course you can replace images in your document. Please see the following forum thread to learn how to replace images with text.
Please let me know in case of any issues, I will be glad to help you.
Best regards.

Thanks for the quick reply! But it’s not exactly what I’m looking for.

I would like to replace an image with another image. Or better yet replace text with an image of my choise. If that is possible I could just type [img1] [img2] and so on where i want the images.

What would be the best way to do this?


Thank you for additional information. I think it is not a good idea to replace text with images. I think the best way to achieve what you need is using mail merge feature. You can easy insert images into the document during mail merge. You just need to insert mergefirld named like “Image:myImg” in the document. Please see the following code example:

// Here we create dummy datasource
DataTable tab = new DataTable("myRegion");
// Add columns
// Add few rows 
tab.Rows.Add(new object[] { "First Image", @"C:\Temp\1.jpg" });
tab.Rows.Add(new object[] { "Second Image", @"C:\Temp\2.jpg" });
tab.Rows.Add(new object[] { "Second Image", @"" });
// etc...
// Open document
Document doc = new Document(@"Test065\in.doc");
// Execute mail merge
// Save output

Also see the attached template and output document.
Hope this helps.
Best regards.