We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How get paragraph?

input.zip (323.6 KB)
i try get paragraph font. 2-nd paragraph, but it always return Times New Roman. But its Courier New.

Document doc = new Document("input.doc");
    foreach (Paragraph para in doc.GetChildNodes(NodeType.Paragraph, true))
    {
       var font = para.ParagraphFormat.Style.Font;
    }

image.png (12.7 KB)

@mesteruh

Please note that formatting is applied on a few different levels. For example, let’s consider formatting of simple text. Text in documents is represented by Run element and a Run can only be a child of a Paragraph. You can apply formatting

  1. to Run nodes by using Character Styles e.g. a Glyph Style .
  2. to the parent of those Run nodes i.e. a Paragraph node ( possibly via paragraph Styles ).
  3. you can also apply direct formatting to Run nodes by using Run attributes ( Font ). In this case the Run will inherit formatting of Paragraph Style, a Glyph Style and then direct formatting.

In your case, we suggest you please get the font name using Run.Font.Name property as shown below.

Document doc = new Document(MyDir + "input.doc");
Paragraph para = (Paragraph)doc.GetChild(NodeType.Paragraph, 1, true);
Console.WriteLine(para.Runs[0].Font.Name);
Console.WriteLine(para.ParagraphFormat.Style.Font.Name);