Search code examples
c#ms-wordxceed

Xceed word get paragraph font properties


I need to get the color, font size and font from the below mentioned paragraph(Heading1). I have looked at How get paragraph FontName with Docx dll? but the font details and color returns null/empty.

Any help or suggestions would be appreciated.

enter image description here

                dummyDocument.ApplyTemplate(wordStyleTemplate);
                dummyDocument.InsertParagraph("Heading1").StyleName = "Heading1";

                dummyDocument.Save();
                dummyDocument.SaveAs(@"C:\DEV\StyleTest.docx");

                var templateHeading1 = dummyDocument.Paragraphs.ToList().FirstOrDefault(x => x.StyleName == "Heading1");
                var color = templateHeading1.MagicText[0].formatting.FontColor; //returns null

Solution

  • I ended up using this Open Xml example to obtain the entire style sheet for the word document, and then extracted the required styles.