Hi Sethumanikkam,
The sample you sent me is actually not 100% what we are after. If we already knew the fields value, why do we need to get it again from event? :-)
Let me paste the method we previously used for other commercial API. They could get the fields value, so when executing it, word document will remove those merge fields but leave static value only. From business point of view we could give these documents to client without containing our company's merged fields. (But unfortunately this API doesn't support .Net Core at this stage.)
public static bool ConvertMergeFieldsToStaticText(Document documentToProcess, string saveFilePath = null)
{
var mergeFields = documentToProcess.MailMerge.GetFieldNames(); while (mergeFields.Any())
{
var fields = documentToProcess.Range.Fields.Cast<Field>().Where(field => field.Type == FieldType.FieldMergeField);
var fieldValues = fields.Select(field => field.Result).Cast<object>().ToArray(); foreach (var field in fields)
{
field.Remove();
}
documentToProcess.MailMerge.Execute(mergeFields, fieldValues); }
documentToProcess.Save(!string.IsNullOrWhiteSpace(saveFilePath) ? saveFilePath : documentToProcess.OriginalFileName);
return true;
}
But doing this, all merge fields will be replaced with static text. Is there any similar way in Syncfusion we could archive what brown line does?
Thanks again!
Samuel