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

Free Support Forum - aspose.com

Where do I look for Style information

Word formats text using Paragraph styles and Character styles.

I have a document whose content is formatted using both Paragraph and Character styles, and there is some text that I can only identify using its Character style, but I don't know where in the doc object hierarchy to look.

If I open the docx file in aspose.words.document and examine doc.FirstSection.Body.FirstParagraph.ParagraphFormat, its Style tells me the Paragraph style.

How do I tell that a particular Run uses a Character style?

Hi Brian,

Thanks for your inquiry. Please use Run.Font.Style.Type property to check either the style type is character or not of a Run node. Please check following code example for your kind reference. Hope this helps you.

Document doc = new Document(MyDir + "in.docx");

foreach (Run run in doc.GetChildNodes(NodeType.Run, true))

{

if (run.Font.Style.Type == StyleType.Character)

Console.WriteLine(run.Font.Style.Name);

}

Many thanks for this Tahir.


I realize now I’d been assuming that Style would be the parent of Font in the object hierarchy - so I hadn’t considered looking inside the Font to access the Style…
Hi Brian,

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.