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

Replace Image tag with Mail Merge Field

Hi all,

I am converting html to word. Html content contains image tag , i want to replace that image tag with those of the mailmerge fields.
can someone suggest a way to do that.

thanks in advance!

8 Replies

GT Gunasekaran T Syncfusion Team May 24, 2012 05:16 AM UTC

Hi Naman,

Thank you for your interest in Syncfusion products.

We have prepared the sample to illustrate your requirement to replace Image tag with Mail Merge field using DocIO. Please do find the sample from the attachment. Try running the sample and let us know if this helps you.

Please let us know if you have any other questions.

Regards,
Gunasekaran



Sample_9d64883.zip


NA Naman Ahuja May 24, 2012 10:50 AM UTC

HI  Gunasekaran ,

thanks for the help but wanted to ask one more things,
how can i insert merge field at a specific position.
supposedly  i have some text and i want to replace it with that of the merge fields , it is possible to do that ?
if yes then how can i do that.?

thanks !!



NA Naman Ahuja May 24, 2012 02:26 PM UTC

Hi Gunasekaran,

Thanks for the sample code.

After seeing your sample code...I am able to identify the image tag and replace it as well.
But problem is, I have 4 different kind of image tags which need to be replaced by their respective MailMerge Field.

I am not able to differentiate between two WPicture objects.
Please tell me how can I differentiate...Different image tags have different source.

Also is there a way by which I can identify my custom tag...I can use custom tag in place of image tag.

Regards
Naman Ahuja


GT Gunasekaran T Syncfusion Team May 25, 2012 05:38 AM UTC

Hi Naman,

Thank you for your update.

We have prepared the sample to illustrate your requirement to replace image tags having unique source with unique Mail Merge Field and replace text with Merge Field. We cannot differentiate WPicture objects based source path of input html image tag; instead we can replace image tag with text in the input html and replace text with merge field while converting it to Word document using DocIO. Please do find the sample for the same from the attachment. Try running the sample and let us know if this helps you.

Please let us know if you have any other questions.

Regards,
Gunasekaran



Sample_2e3bd8f3.zip


NA Naman Ahuja May 28, 2012 04:35 PM UTC

Hi Gunasekaran,

Instead of replacing text with MergeField object, is there a way by which I can replace the text within the HTML itself... and then convert that HTML directly into doc file. 
So when converting html to doc, it will directly convert the the given html (for merge field)  into merge field in doc .



GT Gunasekaran T Syncfusion Team May 29, 2012 04:27 AM UTC

Hi Naman,

Thank you for your update.

We have prepared the sample to illustrate your requirement to replace text tags with html contents using DocIO. Please do find the sample for the same from the attachment. Try running the sample and let us know if this helps you.

Please let us know if you have any other questions.

Regards,
Gunasekaran



Sample_fb6e2051.zip


DY Dyana December 17, 2012 06:18 AM UTC

Hi Gunasekaran.

I had the same problem but my html code is not in html document. But I collect it in string variable like :

string htmlContent = <p style='text-align: center'>  <strong>please </strong>pick my clothes <u>in my home </u><em>and dont forget the keys. </em><span style='color: #ff0000'>it is my house</span>  </p> <p style='text-align: center'>  <img alt='' src='template/home.jpg' style='width: 272px; height: 209px' /></p>

how about it? I try to use your sample before but it's not work with StreamReader. Thanks :)


DY Deivaselvan Y Syncfusion Team January 2, 2013 04:38 AM UTC

Hi Dyana,

Thank you for your update.

I would like to inform you that this query is a replica of the query mentioned in the forum #106177, Please follow-up with the forum #106177 for a resolution.

Please let us know if you have any other questions.

Regards,
Deiva selvan


Loader.
Live Chat Icon For mobile
Up arrow icon