Re: Merged Text Prints in Different Font During Mail Merge

I have stumbled across this post while investigating this exact issue.
We are using .NET Aspose Words v15.4.

This has recently started happening following an .Words version update. Can you confirm if this is a regression bug and when it will be fixed if so.

Thanks
Glyn Jones

Hi Glyn,

Thanks for your inquiry. Please attach your input template Word document, output Word document showing the undesired behavior and source code without compilation errors here for testing. Please provide information about the exact Aspose.Words’ version number for which there were no problems on your side previously. We will investigate the issue on our end and provide you more information.

Best regards,

I’ve finally managed to come back a revisit this one. Upon some further checking I noticed that when I selected the merge field in the doc template, the font size disappeared suggesting more than one font was represented. I don’t know how that happened because the merge field appears as a single font. No part of the token displays as anything other than the expected font. When I set a single font for the merge field the issue is resolved.

Hi Glyn,

It is great you were able to find what you were looking for. Please let us know any time you have any further queries.

You can also use the following code to check what Runs inside merge field are formatted with what Font:

foreach (Field field in doc.Range.Fields)
{
    if (field.Type.Equals(FieldType.FieldMergeField))
    {
        Node currentNode = field.Start;
        bool isContinue = true;
        while (currentNode != null && isContinue)
        {
            if (currentNode.NodeType.Equals(NodeType.FieldEnd))
                isContinue = false;
            if (currentNode.NodeType.Equals(NodeType.Run))
                Console.WriteLine(((Run)currentNode).Font.Name);
            Node nextNode = currentNode.NextPreOrder(currentNode.Document);
            currentNode = nextNode;
        }
    }
}

Hope, this helps.

Best regards,