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

Free Support Forum - aspose.com

Removing Style property for a Run


How can we remove specific properties on a Run. For example we have a run as:

		<w:rStyle w:val="DefaultParagraphFont"/>

I would like to remove the Style property completely. So the run is like:


One approach is to clone the run and set value using run.text = "Some value". But this may not work always, because in case if the the document has track changes enabled, this change will be treated as a redline. Is there a cleaner way ?

Thanks !

@kml2020 You can use Font.clearFormatting() method to achieve this:

Document doc = new Document("C:\\Temp\\in.docx");
Iterable<Run> runs  = doc.getChildNodes(NodeType.RUN, true);
for (Run r : runs) {

But please note, using Aspose.Words you cannot work with XML representation of the document directly. When you open the document using Aspose.Words it is read into the DOM, and further changes are made in the DOM, not in the XML.

1 Like

Your suggestion works great, @alexey.noskov. Thank you for the response!

1 Like