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

Free Support Forum - aspose.com

.doc file doesn't retain unused Style levels

Hi Aspose,

I attached sample.doc sample.zip (5.0 KB)

The original file has 9-levels Style and use 3 levels only. When I loaded via Aspose and saved to new .doc, the output file retained 3 levels that are using only.

Please help me check this case. Is it possible to maintain all the Style?

Thank you,
Dung H. Nguyen


Thanks for your inquiry. We have tested the scenario using Aspose.Words for .NET 17.8 and noticed that all the styles are being retained in resultant DOC file. Please find attached sample output for your reference. If you are using some old version of Aspose.Words for .NET, then please download and try latest version of Aspose.Words for .NET. It will help you to resolve the issue.Test_AW178.zip (10.4 KB)

Document doc = new Document(@"sample.doc");

Hi @tilal.ahmad

Thanks for your info.

I’ve tested v17.8, but the Styles are still truncated.
I think the cause is RemoveUnusedResources().

Can you give me what are the differences between RemoveUnusedResources and CleanUp (in v17.8) ?
What is the “unused list”?

Are there any other objects/resources be removed?

Thank you,
Dung H. Nguyen


Thanks for your feedback. Please note RemoveUnusedResources is obsolete now, it is recommended to use CleanUp method. You can remove both unused styles and lists or use CleanupOptions for any customization. Please check following documentation for details.

Furthermore, please confirm have you noticed style truncation in our above shared output? If you still notice any issue, then please share a sample console application along with the input/output documents and some screen shots to describe the issue you are facing. You can ZIP the resources and attach to the post. We will further investigate the issue and will guide you accordingly.

Hi @tilal.ahmad

Thank you.
I uploaded a wrong sample. I’m so sorry. :frowning:
This is the correct one, sample2.zip (9.0 KB)

Anyway, when setting UnusedStyles = false, result is good enough. However, I’d like to be confirmed that does CleanUp method only remove unused styles and lists?

Thank you,
Dung H. Nguyen


Thanks for your feedback. It is good to know you have managed to resolve the issue. API retains all the styles with default settings. It seems you are removing unused styles from the document so unused styles are being removed from your document.
Source.png (96.7 KB)
AW 178.png (94.3 KB)

Document doc = new Document("Number test.doc");