Thanks for your inquiry. Your document contains alias styles E.g CustomStyle10 has alias C10 and cm10. This is the reason you are getting style count as 44. Please use Style.getAliases method to get all aliases of a style. If style has no aliases then empty array of string is returned.
If you
want to iterate through only unique styles in a document, please use following code example.
Document doc = new Document(MyDir +"StyleIterate.docx");
for(int i = 0; i < doc.getStyles().getCount(); i++)
{
System.out.println(doc.getStyles().get(i).getName());
}
But it think this is very confusing for users of your Java API. I really think you have to do something about it :
- If this is not expected behavior : it should be fixed sooner or later.
- If this is expected behavior (i think it should not but i’m not an Aspose API designer) : you have to update java documentation of this call to warn users of your API that document.getStyles() will iterate over style names AND style aliases. And how to do to iterate only through unique styles
Thanks for your inquiry. This is the expected behavior of Aspose.Words. We will update the documentation about Document.Styles property. We apologize for your inconvenience.