How to Get color of paragraph


#1

Hi,
I want to find color of paragraph(let’s say paragraph after Abstract) given in attached screenshot.
Can anyone please help me with this.
textColor.PNG (9.2 KB)


#2

@komalm2921,

You can use the following code to return the Color of all text (paragraphs etc) in document:

Document doc = new Document("E:\\temp\\warningsout.docx");
doc.JoinRunsWithSameFormatting();

foreach (Paragraph targetPara in doc.GetChildNodes(NodeType.Paragraph, true))
{
    foreach (Run run in targetPara.GetChildNodes(NodeType.Run, true))
    {
        Console.WriteLine(run.Font.Color.Name);
    }
}