How get paragraph FontName with Docx dll?

2019-07-18 03:04发布

问题:

I am using Docx dll to get paragraph information but not able to get paragraph format(font size-fontName-FontColor) Here is my code for that:

        using (DocX document = DocX.Load("Test.docx"))
        {

            if (document.Paragraphs.Count() > 0)
            {

                for (int i = 0; i < document.Paragraphs.Count; i++)
                {
                    Novacode.Paragraph pg = document.Paragraphs[i];
                    Console.WriteLine("Text:" + pg.Text +" Alignment:" + pg.Alignment + " Direction:" + pg.Direction);
                    //how get FontName
                }
            }
        }

回答1:

You can do this:

pg.magictext[i].formatting.fontfamily.name.tostring()


标签: docx