How to Accept Tracked Changes in Java

How to Accept Tracked Changes in Java

Aspose.Words FOSS for Java accepts the tracked changes of a reviewed Word document in one call. This guide opens a reviewed document, accepts every revision, and saves the final version, with the library from Maven Central.

Step-by-Step Guide

Step 1: Install the Package

Add the package to your build. The library needs Java 8 or later.

<dependency>
  <groupId>org.aspose</groupId>
  <artifactId>aspose-words-foss</artifactId>
  <version>26.3.0</version>
</dependency>

Step 2: Import the Classes

All classes are in the com.aspose.words package, so the example starts with import com.aspose.words.*;.


Step 3: Accept All Revisions

Tracked changes are called revisions in the API. acceptAllRevisions accepts all tracked changes in the document. Save the result under a new name so the reviewed original stays available.

import com.aspose.words.*;

Document doc = new Document("reviewed.docx");
doc.acceptAllRevisions();
doc.save("final.docx");

Common Issues and Fixes

The compiler reports cannot find symbol for Document. The com.aspose.words package is not imported. Add import com.aspose.words.*;.

Opening the file throws a FileNotFoundException. The message reads “Can’t find file” followed by the name. Check that reviewed.docx exists in the directory the program runs in.

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.

Frequently Asked Questions

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.

See Also