Accept or Reject Revisions
Leave feedback
On this page
GroupDocs.Comparison for Python via .NET can extract Word track-change revisions from a DOCX file, let you accept or reject each one, and save the updated document.
To process revisions, follow these steps:
- Instantiate a
RevisionHandlerand provide the source document path or stream. - Call
get_revisions()to retrieve the list of revisions. - For each revision, set
actiontoRevisionAction.ACCEPTorRevisionAction.REJECT. - Call
apply_revision_changes()with the result file path andApplyRevisionOptionscontaining the decisions.
from groupdocs.comparison.words.revision import RevisionHandler, RevisionAction, ApplyRevisionOptions
def accept_or_reject_revisions():
with RevisionHandler("./Document_with_revision.docx") as revision_handler:
revisions = revision_handler.get_revisions()
for revision in revisions:
if revision.type == "Insertion":
revision.action = RevisionAction.ACCEPT
else:
revision.action = RevisionAction.REJECT
options = ApplyRevisionOptions()
options.changes = revisions
revision_handler.apply_revision_changes("./result.docx", options)
if __name__ == "__main__":
accept_or_reject_revisions()
Document_with_revision.docx is the source file used in this example. Click here to download it.
Binary file (DOCX, 21 KB)
from groupdocs.comparison.words.revision import RevisionHandler, RevisionAction, ApplyRevisionOptions
def accept_or_reject_revisions_stream():
with open("./Document_with_revision.docx", "rb") as source_stream:
with RevisionHandler(source_stream) as revision_handler:
revisions = revision_handler.get_revisions()
for revision in revisions:
if revision.type == "Insertion":
revision.action = RevisionAction.ACCEPT
options = ApplyRevisionOptions()
options.changes = revisions
revision_handler.apply_revision_changes("./result.docx", options)
if __name__ == "__main__":
accept_or_reject_revisions_stream()
Document_with_revision.docx is the source file used in this example. Click here to download it.
Binary file (DOCX, 21 KB)
To apply a single decision to every revision in the document, set common_handler on ApplyRevisionOptions:
from groupdocs.comparison.words.revision import RevisionHandler, RevisionAction, ApplyRevisionOptions
def accept_all_revisions():
with RevisionHandler("./Document_with_revision.docx") as revision_handler:
options = ApplyRevisionOptions()
options.common_handler = RevisionAction.ACCEPT
revision_handler.apply_revision_changes("./result.docx", options)
if __name__ == "__main__":
accept_all_revisions()
Document_with_revision.docx is the source file used in this example. Click here to download it.
Binary file (DOCX, 21 KB)
| Source file | Result file |
|---|---|
![]() | ![]() |
- Accept or reject detected changes — accept/reject between two documents (this page is about revisions inside a single document).
- Word track changes — control whether comparison emits new revisions in the result.
- Setting author of changes — attribute new revisions to a specific author.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.

