In MS-Word 2010, there is an option in the File → Information section to check a document for problems before sharing it. This allows you to process track changes (to the newest new version) and immediately delete all comments and annotations from the document.

Is this feature available in docx4j, or do I need to examine the relevant JAXB objects and write traverse? Doing this manually can be a lot of work, since I have to add RunIns( w:ins) to R( w:r) and delete RunDel( w:del). I also saw w:delonce inside w:ins. In this case, I do not know if it appears the other way around or in deeper nests.
Further research led to this XSLT:
https://github.com/plutext/docx4all/blob/master/docx4all/src/main/java/org/docx4all/util/ApplyRemoteChanges.xslt
I could not run this in docx4j, but manually unpacking docx and extracting document.xml. After applying xslt to plain document.xml, I wrapped it again in a docx container to open it with MS-Word. The result was not the same as when accepting the version with MS-Word. More specific: XSLT deleted the deleted selected text (in the table), but was not a point in front of the text. This is often found in my document.
, . ContentAccessor, String. ContentAccessor P Tc. R a RunIns ( R ). . else if (child instanceof RunIns) {. , , , del/ins, . , MS-Word.
private String getAllTextfromParagraph(ContentAccessor ca) {
String result = "";
List<Object> children = ca.getContent();
for (Object child : children) {
child = XmlUtils.unwrap(child);
if (child instanceof Text) {
Text text = (Text) child;
result += text.getValue();
} else if (child instanceof R) {
R run = (R) child;
result += getTextFromRun(run);
}
else if (child instanceof RunIns) {
RunIns ins = (RunIns) child;
for (Object obj : ins.getCustomXmlOrSmartTagOrSdt()) {
if (obj instanceof R) {
result += getTextFromRun((R) obj);
}
}
}
}
return result.trim();
}
private String getTextFromRun(R run) {
String result = "";
for (Object o : run.getContent()) {
o = XmlUtils.unwrap(o);
if (o instanceof R.Tab) {
Text text = new Text();
text.setValue("\t");
result += text.getValue();
}
if (o instanceof R.SoftHyphen) {
Text text = new Text();
text.setValue("\u00AD");
result += text.getValue();
}
if (o instanceof Br) {
Text text = new Text();
text.setValue(" ");
result += text.getValue();
}
if (o instanceof Text) {
result += ((Text) o).getValue();
}
}
return result;
}