Free Support Forum - aspose.com

Aspose Word - Character Styles and Local Formatting

Hi,

I'm currently processing a document to convert from one character style to another, but I need to know if the source character style has any local formatting applied and therefore determine the difference between the original character style and what has been overridden by the user. For example:

This a paragraph with which has "Para Style 1" style, but some of its content has some Character styles based on "Char Style 1" Character Style, and some additional Local Formatting applied on top of the "Char Style 1"

How can I determine the local formatting of a character style and the difference between the character style and what has been locally formatted.

Many thanks

Russell

Hi Russell,


Thanks for your inquiry. The formatting applied to text in a Microsoft Word document can come from many different sources. A useful thing to note about the Aspose.Words’ API is that querying direct formatting (Run.Font, Paragraph.ParagraphFormat) will normally return the “calculated” formatting value based on all direct formatting, styles and document defaults etc. Therefore, using the direct formatting properties are the best way to find the visible formatting of the content.
Russell:
How can I determine the local formatting of a character style and the difference between the character style and what has been locally formatted.
I think there is no direct way to find out this. Maybe you can get this style and compare its formatting with your direct run formatting. But if Run has the same direct formatting as style, there will not be any difference. Another approach would be to copy the final visible formatting of text into a temporary style and then subtract the character style formatting from this new style. Please let me know if I can be of any further assistance.

Best regards,