Document Attached(TestStyle.docx) to show/use in the example…
Created a document with user defined styles (Refer document TestStyle.docx attached with styles:Topic Style, Question Style, Answer Style )
Trying to Read the style using the code as shown at the end of this post:
All the styles are considered as “Default Paragraph Text”, Aspose is not recognizing the styles.
Sometime is does. It is not consistent. Am i doing something wrong?
Thanks in advance .
Code :
// Sample Code
// Calling the Method
ReadStyle(@"c:\Test\Teststyles.docx");
private Document ReadStyle(Document docforReadingStyles)
{
NodeCollection runs = docChangeStyles.GetChildNodes(NodeType.Run, true);
int CountTopics = 0;
int CountQuestions = 0;
// Loop through every run node.
foreach(Run run in runs)
{
if (run.Font.StyleName.Contains("Topic"))
{
CountTopics++;
}
if (run.Font.StyleName.Contains("Question"))
{
CountQuestions++;
}
}
}
This message was posted using Page2Forum (attachment) from Aspose.Words for .NET - Documentation