We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Finding and replacing images in a docx

I'm currently evaluating a copy of Syncfusion Essential Studio and am working with DocIO right now. I want to be able to find images in a docx and replace them with different images.

How may I go around doing that?

6 Replies

RM Ramkumar M Syncfusion Team September 3, 2012 10:50 AM UTC

Hi Alexander,

Thank you for your interest in Syncfusion products.

We have created a sample to meet your requirement of find and replace particular images in document with other image by checking its unique Alternative text. Please do find the sample from below link and let us know if this helps you.

Sample Link:

http://www.syncfusion.com/downloads/Support/DirectTrac/98317/Sample1229886910.zip

Please let us know if you have any questions

Regards,

Ramkumar



TH Tobias Heer November 15, 2019 04:42 PM UTC

Hi

I also need to replace images in a docx document but it seems that i am not able to download the sample project.

Could you provide a working download  link for the sample again?

Thank you.


PR Poorani Rajendran Syncfusion Team November 18, 2019 06:16 AM UTC

Hi Tobias,

Thank you for your update.

To meet your requirement, we suggest you set the unique alternate text for the picture in the input Word document and use Picture.AlternativeText API to find the particular image from the Word document and replace it with different image using Essential DocIO. We have prepared sample application for the same and it can be downloaded from the below link:
https://www.syncfusion.com/downloads/support/forum/104983/ze/CreateWordSample-1237063560

Note: Please find the input Word document in “Data” folder of above sample application.

In the above sample application we have done following things,
1. Opens an existing Word document.
2.Iterates to the section and textbody elements.
3.Finds the particular picture using Picture.AlternativeText API.
4.Removes the picture from the paragraph.
5.Inserts new picture at the same index to the paragraph.
6.Saves the Word document.

Please let us know if you have any other questions.

Regards,
Poorani Rajendran




AA Adnan Ali February 22, 2022 05:15 PM UTC

The solution is working perfectly, But when we save document with Document Editor Alternative text and title value is set to null, Hence the solution breaks. Can you please recheck and suggest any solution



MR Manikandan Ravichandran Syncfusion Team February 23, 2022 03:17 PM UTC

Hi Adan Ali,

Currently, we are checking your query and we will update the details on 24th February 2022.

Regards,
Manikandan Ravichandran 



MR Manikandan Ravichandran Syncfusion Team February 24, 2022 06:52 AM UTC

Hi Adan Ali,

Thanks for your patience.

Please share the below details to proceed further.
     1. Can you please share the code snippet which you have used to save the Document in Document editor?
     2. Document editor platform and version details.
     3. Are you facing this issue for all document or specific document? if specific document, please share the document to proceed further.

Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same. We just need your document to recreate the problem you face.

Regards,
Manikandan Ravichandran 


Loader.
Live Chat Icon For mobile
Up arrow icon