Tracked Changes
Overview
Tracked changes are called revisions in the API. A Revision represents a revision (tracked change) in a document node or style, and the RevisionCollection from Document.getRevisions holds the ones in a document. This page shows how to accept all of them at once, which turns a reviewed document into its final version.
Prerequisites
| Requirement | Detail |
|---|---|
| Java | 8 or later |
| Dependency | The package from Installation |
| Import | import com.aspose.words.*; |
Accept All Tracked Changes
Open the reviewed document, call acceptAllRevisions, and save the result under a new name.
import com.aspose.words.*;
Document doc = new Document("reviewed.docx");
doc.acceptAllRevisions();
doc.save("final.docx");Tips and Best Practices
- Save to a new file name, as the example does, so the reviewed original stays available.
Revisionhasacceptandrejectmethods, andRevisionCollectionhasacceptAllandrejectAll. This guide showsDocument.acceptAllRevisions.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
The compiler reports cannot find symbol for Document. | The com.aspose.words package is not imported. | Add import com.aspose.words.*;. |
| The compiler reports an unreported exception. | The Document constructors, Document.save and some other methods declare throws Exception. | Declare it on the calling method or catch it. |
FAQ
What does acceptAllRevisions do?
It accepts all tracked changes in the document.
Where do I find the individual revisions?
Document.getRevisions gets a collection of revisions (tracked changes) that exist in the document.
Can I reject the changes instead?
RevisionCollection has a rejectAll method. This guide has no example for it.
API Reference Summary
| Class / Method | Description |
|---|---|
Document.acceptAllRevisions() | Accepts all tracked changes in the document. |
Document.getRevisions() | Gets a collection of revisions (tracked changes) that exist in this document. |
Revision | Represents a revision (tracked change) in a document node or style. |
RevisionCollection | A collection of Revision objects that represent revisions in the document. |