I am using the Aspose Words API to extract text. However, I am not sure how to extract text data that has been accepted through Word’s revision feature. How can I do this?
To retrieve revisions in a Word document using the Aspose.Words API, you can follow these steps:
-
Load the Word Document: First, you need to load the document that contains the revisions. You can do this by specifying the path to your document.
-
Access the Revisions Collection: Aspose.Words provides a collection of revisions that you can iterate through. This allows you to access each revision made in the document.
-
Extract Revision Details: Within the loop, you can extract various details about each revision, such as the type of revision (insertion, deletion, formatting change), the author, the date of the change, and the text associated with the revision.
-
Accept or Reject Revisions: After reviewing the revisions, you can choose to accept or reject them programmatically. This can be done for all revisions at once or selectively for individual revisions.
Here’s a code example demonstrating how to achieve this in C#:
// Load the Word document
Document doc = new Document("path/to/your/document.docx");
// Access the revisions collection
RevisionCollection revisions = doc.Revisions;
// Iterate through each revision and extract details
foreach (Revision revision in revisions)
{
Console.WriteLine("Revision Type: " + revision.RevisionType);
Console.WriteLine("Author: " + revision.Author);
Console.WriteLine("Date: " + revision.DateTime);
Console.WriteLine("Content: " + revision.ParentNode.GetText());
}
// Accept all revisions
doc.AcceptAllRevisions();
// Save the modified document
doc.Save("path/to/modified/document.docx");
In this example, the RevisionCollection
allows you to access all revisions, and you can print out the details for each revision. After reviewing, you can accept all revisions to finalize the document.
For more detailed information on managing revisions, you can refer to the official documentation on tracking changes and handling revisions with Aspose.Words here and here.
If you have any further questions or need additional assistance, feel free to ask!
Thank you for your response!
The example using the C# SDK is easy to understand.
I am using the Aspose Cloud Node.js SDK.
After checking the references, I couldn’t find an API to retrieve revisions.
https://docs.aspose.cloud/words/spec/
Is this feature not supported in the Cloud version?
This topic has been moved to the related forum: Can I retrieve revisions in Word? - Free Support Forum - aspose.cloud