If you are collaborating with multiple people on contracts or school assignments, tracking changes can be very useful because it helps you to review each change made by other people, and you can decide whether to accept or reject those changes. In this article, I will share how to accept or reject all tracked changes in a Word document using Free Spire.Doc for Java.
Import Jar Dependency (2 methods)
● Download the Free Spire.Doc for Java and unzip it, then add the Spire.Doc.jar file to your Java application as dependency.
● Directly add the jar dependency to maven project by adding the following configurations to the pom.xml.
<repositories>
<repository>
<id>com.e-iceblue</id>
<name>e-iceblue</name>
<url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>e-iceblue</groupId>
<artifactId>spire.doc.free</artifactId>
<version>3.9.0</version>
</dependency>
</dependencies>
Sample Code
import com.spire.doc.Document;
import com.spire.doc.FileFormat;
public class AcceptOrRejectChanges {
public static void main(String[] args) {
//Create a Document object
Document doc = new Document();
//Load the sample Word file
doc.loadFromFile("Oscar Wilde.docx");
//Accept all changes in the entire document
doc.acceptChanges();
////Reject all changes in the entire document
//doc.rejectChanges();
//Save the document
doc.saveToFile("AcceptAllChanges.docx", FileFormat.Docx);
}
}
Top comments (0)