Free Support Forum - aspose.com

Document.Cleanup() not removing all unused styles and lists

I have a very simple test where I am opening an input document and Copies styles from the input1.xml & input2.xml to the input.docx document and imported all content into the input.docx document.

After that, I used Document.Cleanup() with the following options

 CleanupOptions cleanupOptions = new CleanupOptions();
 cleanupOptions.DuplicateStyle = true;
 cleanupOptions.UnusedStyles = true;
 cleanupOptions.UnusedLists = true;
 document.Cleanup(cleanupOptions);

But all unused styles and lists are not removed after Cleanup().

I have created a sample demo application to reproduce this issue, PFA.

SampleCode.zip (42.2 KB)

@GZaha,

We have logged this problem in our issue tracking system. Your ticket number is WORDSNET-21978. We will further look into the details of this problem and will keep you updated here on the status of the linked issue. We apologize for any inconvenience.

The issues you have found earlier (filed as WORDSNET-21978) have been fixed in this Aspose.Words for .NET 21.4 update and this Aspose.Words for Java 21.4 update.

@GZaha

We added a new public property CleanupOptions.UnusedBuiltinStyles in Aspose.Words 21.4 to remove unused built-in styles from document. You can also use this property to remove built-in styles from the document if you want.

Document doc = new Document("input.docx");
CleanupOptions cleanupOptions = new CleanupOptions();
cleanupOptions.UnusedBuiltinStyles = true;
doc.Cleanup(cleanupOptions);