LINQ Reporting Engine - Unable to fill background color with text superimposed on it in a texbox

I want to fill multiple textboxes with a certain number and a background color which depends on the number. My source code is as follows: -

Paragraph lastParagraph = document.LastSection.Body.LastParagraph;

// Set left alignment for the paragraph.
lastParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;
// Run run = new Run(document);
NodeCollection shapes = document.GetChildNodes(NodeType.Shape, true);
var textBoxText1 = root[2].Domain.RiskScore;
var textBoxText2 = root[3].Domain.Area[0].RiskScore;

Dictionary<string, (string text, string color)> textboxValues1 = new Dictionary<string, (string, string)>
    {
        { "<<if [IndexOf() == 2] >> <<[domain.RiskScore]>><</if>>", (textBoxText1, "Yellow") },
        { "<<if [IndexOf() == 3] >><<foreach [in domain.Areas]>><<if [IndexOf() == 0]>>", (textBoxText2, "Green") }
    };
foreach (Shape shape in shapes)
{
    if (shape.ShapeType == ShapeType.TextBox)
    {
        int i = 0;
        foreach (var entry in textboxValues1)
        {
            // Find the first paragraph inside the shape
            Paragraph paragraph = shape.GetChildNodes(NodeType.Paragraph, true)[i] as Paragraph;

            // Adjust the font size
            foreach (Run run in paragraph.Runs)
            {
                run.Font.Size = 40;
                run.Font.Color = Color.White;
            }
            i++;
            shape.VerticalAlignment = VerticalAlignment.Center;

        }
    }
}

The section above pertains specifically to the part where I am attempting to replace the placeholders inside the textboxes with the number and the background color.
However, it is filling up only the first textbox. Below is the placeholder text in the template file:-
<<foreach [in domains]>> <<if [IndexOf() == 2] >> <<backColor[domain.Color]>> <<[domain.RiskScore]>> <</backColor>> <</if>> <</foreach>>

Kindly help me identify any missing or wrong step here. I am posting an image where the figure on the right is what I want to achieve, whereas, the one on the left is what I am able to generate.

@ashlosh Could you please attach the input document and desired output?

in the original post, you will find the image having both the desired outcome and the attempt

@ashlosh

It seems, the issue is due to extra spaces you apply before opening and after closing backColor tags. As per the last paragraph of Setting Background Color Dynamically, all text content of a textbox should be enclosed with backColor tags in order a textbox fill to be applied. Also, the textbox’s fill should be set to “No Fill” in the template in this case.