We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Edit mergefields of the document to make it as Image:+mergefield name

hi aspose,
I want to edit the merge field to make the field Image:+ mergefield name. i have the merge fields in the document. some of the mergefields in the document should be replaced with the images.
If i can edit the merge field then i can attach the image to it.
so please tell me

  1. how can i edit the mergefield and attach the Image: tag to the mergefield to that aspose recognises it as image mergefield.
  2. How can replace the merge field with the image.

thanks and regards,
bhaskar,

Hi
Thank you for your interest in Aspose products.

  1. Yes you can edit mergefields using Aspose.Words. See the following link for more information.
    https://docs.aspose.com/words/net/fields-overview/
    Also see the following code:
NodeList fieldStarts = doc.SelectNodes("//FieldStart");
foreach (FieldStart fieldStart in fieldStarts)
{
    if (fieldStart.FieldType == FieldType.FieldMergeField)
    {
        MergeField mergeField = new MergeField(fieldStart);
        string name = mergeField.Name;
        if (name == "Test")
        {
            mergeField.Name = "Image:Test";
        }
    }
}
  1. You can use MergeImageField event to achieve this. See the following links for more information.
    https://reference.aspose.com/words/net/aspose.words.mailmerging/ifieldmergingcallback/imagefieldmerging/

Please let me know if you would like to know something else.
Best regards.

Hi Alexey,

We have a doubt regarding the renaming of a mergefield. The Current API doesn’t seem to support the class “MergeField”. Is it deprecated? If not, what is the current equivalent class for the same. We have a scenario where the name of the mergefield in the template should be changed dynamically, based on aset of rules.
Any help in this regard will be apprecitaed.

Thanks and Regards,
Pavithra V S

Hi

Thanks for your request. You can find an implementation of MergeField class here:
https://docs.aspose.com/words/net/fields-overview/
Best regards.