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);

It seems that I’m encountering an issue with the document cleanup process. I have a straightforward test in which I open an input document and copy styles from the “input1.xml” and “input2.xml” files to the “input.docx” document. Following this, I import all the content into the “input.docx” document.

Subsequently, I utilize the Document.Cleanup() function with the specified options:

csharp

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

However, it appears that despite applying the cleanup with the specified options, unused styles and lists are not being removed as expected. To help identify and resolve this issue, I’ve created a sample demo application that demonstrates the problem. Please find the demo application attached (PFA).

@hofika3 Unfortunately, I do not see any attachments. Could you please reattach your demo application? Please make sure you are using the latest version of Aspose.Words. Also, please specify which exact style are not removed from the output document.