Revisions
Revisions
This guide shows how to inspect, accept, reject, and record tracked changes in a Word document with Aspose.Words FOSS for .NET. Aspose.Words FOSS for .NET can inspect, accept, and reject tracked changes (revisions) in a Word document through Document.Revisions, and can record new tracked changes while editing via Document.StartTrackRevisions()/StopTrackRevisions().
Reading Tracked Changes
Document.Revisions returns a RevisionCollection of every Revision in the document; Range.Revisions scopes the same to a specific range. Each Revision reports who made the change and when (Author, DateTime), what kind of change it is (RevisionType: Insertion, Deletion, FormatChange, StyleDefinitionChange, or Moving), and where it applies (ParentNode, ParentStyle). Document.HasRevisions tells you up front whether a loaded document has any tracked changes at all.
Accepting and Rejecting Revisions
Call Revision.Accept() or Revision.Reject() to resolve a single tracked change, or work on the whole collection at once with RevisionCollection.AcceptAll() / RejectAll(). Document.AcceptAllRevisions() is a document-level convenience that accepts every revision in one call. To accept or reject a subset selectively, implement IRevisionCriteria.IsMatch(revision) and pass it to RevisionCollection.Accept(criteria) or Reject(criteria).
Revision Groups
Consecutive revisions from the same author and of the same type are exposed together as a RevisionGroup — accessible via Revision.Group for a single revision, or RevisionCollection.Groups (a RevisionGroupCollection) for every group in the document. Each group reports its combined Text, Author, and RevisionType.
Recording New Tracked Changes
Call Document.StartTrackRevisions(author) or the overload StartTrackRevisions(author, dateTime) before making edits so that subsequent changes are recorded as revisions rather than applied directly; call StopTrackRevisions() to end tracking. The Document.TrackRevisions property reflects whether tracking is currently active.
Viewing Original vs. Final Content
Document.RevisionsView controls whether the document is presented in its Original or Final state (a RevisionsView value) when revisions are present, without altering the underlying revision data.
Tips and Best Practices
- Check
Document.HasRevisionsbefore iteratingDocument.Revisionsto skip unnecessary work on documents with no tracked changes. - Prefer
RevisionCollection.Accept(criteria)/Reject(criteria)with a customIRevisionCriteriaover manually filtering and callingRevision.Accept()one at a time. RevisionGroupis useful for presenting a readable summary of changes — grouping consecutive same-author, same-type revisions avoids treating every inserted character as a separate entry.- Always pair
StartTrackRevisions()with a laterStopTrackRevisions()call so unrelated edits aren’t recorded as tracked changes.
Common Issues
| Issue | Cause | Fix |
|---|---|---|
Document.Revisions is empty after edits | StartTrackRevisions() was never called before editing | Call StartTrackRevisions(author) before making edits you want tracked |
RevisionCollection.Accept(criteria) accepts nothing | IRevisionCriteria.IsMatch() doesn’t match any revision | Verify the criteria logic against actual Revision.Author/RevisionType/ParentNode values first |
Document still shows tracked-change markup after AcceptAllRevisions() | View state, not revision data | Set Document.RevisionsView to Final if you need the resolved content view |
FAQ
How do I check whether a document has any tracked changes?
Read Document.HasRevisions — it’s true if Document.Revisions contains at least one Revision.
What’s the difference between Revision.Accept() and RevisionCollection.AcceptAll()?
Revision.Accept() resolves one specific revision; RevisionCollection.AcceptAll() (or Document.AcceptAllRevisions()) resolves every revision in the collection at once.
How do I accept only revisions made by a specific author?
Implement IRevisionCriteria.IsMatch(revision) to check revision.Author, then call RevisionCollection.Accept(criteria) with that implementation.
How do I record my own edits as tracked changes?
Call Document.StartTrackRevisions(author) before making the edits, then Document.StopTrackRevisions() when done.
What revision types exist?
RevisionType defines Insertion, Deletion, FormatChange, StyleDefinitionChange, and Moving.
API Reference Summary
| Class / Method | Description |
|---|---|
Document.Revisions | RevisionCollection of all tracked changes in the document |
Revision | One tracked change: Author, DateTime, RevisionType, Accept(), Reject() |
RevisionCollection | AcceptAll(), RejectAll(), Accept(criteria), Reject(criteria), Groups |
RevisionGroup / RevisionGroupCollection | Consecutive same-author, same-type revisions grouped together |
IRevisionCriteria | Custom predicate (IsMatch(revision)) for selective accept/reject |
Document.StartTrackRevisions() / StopTrackRevisions() | Record new edits as tracked changes |
Document.RevisionsView | Original or Final presentation of revised content |