Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Sometimes you may need to remove unused or duplicate information to reduce the size of the output document and processing time.
While you can find and remove unused data, such as styles or lists, or duplicate information manually, it will be much more convenient to do this using features and capabilities provided by Aspose.Words.
The CleanupOptions class allows you to specify options for document cleaning. To remove duplicate styles or just unused styles or lists from the document, you can use the Cleanup method.
You can use the UnusedStyles and UnusedBuiltinStyles properties to detect and remove styles that are marked as “unused”.
You can use the UnusedLists property to detect and remove lists and list definitions that are marked as “unused”.
The following code example shows how to remove only unused styles from a document:
You can also use the DuplicateStyle property to substitute all duplicate styles with the original one and remove duplicates from a document.
The following code example shows how to remove duplicate styles from a document:
Q: How can I remove unused styles from a Word document using Aspose.Words for Java?
A: Create a CleanupOptions instance, set setUnusedStyles(true), and call document.cleanup(options). This removes any style definitions that are not applied in the document.
Q: How do I delete duplicate styles in a document?
A: Enable the setDuplicateStyle(true) option on CleanupOptions and invoke document.cleanup(options). Aspose.Words will replace duplicate style definitions with the original one and remove the extras.
Q: Can I also clean up unused built‑in styles and lists?
A: Yes. Set setUnusedBuiltinStyles(true) and/or setUnusedLists(true) on the same CleanupOptions object before calling cleanup. All specified unused elements will be removed in one pass.
Q: Does the cleanup process affect the document’s visible content?
A: No. Cleanup only removes unused or duplicate style and list definitions; it does not modify the actual text, images, or other visible content of the document.
Q: Is it possible to combine multiple cleanup options in a single call?
A: Absolutely. You can enable several options (e.g., UnusedStyles, UnusedLists, DuplicateStyle) on one CleanupOptions instance and call document.cleanup(options) once to apply all selected clean‑up actions.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.