How to fetch revision for a paragraph or rich text content control in aspose words java

Hi Team,

Is it possible to extract revisions present on a particular paragraph or rich text content control?

I am able to extract overall revisions on a document. But is it possible to extract for a particular node.

Thanks

@ashu_agrawal_sirionlabs_com

Yes, it is possible to extract revisions for a specific paragraph or rich text content control using Aspose.Words for Java. While you can retrieve overall revisions for the entire document, you can also focus on revisions related to specific nodes, such as paragraphs or content controls.

To achieve this, you can follow these steps:

  1. Load the Document: First, load your document using the Document class.
  2. Access the Node: Navigate to the specific paragraph or content control you are interested in.
  3. Retrieve Revisions: Use the getRevisions() method on the node to get the revisions associated with that particular node.

Here is a sample code snippet demonstrating how to extract revisions for a specific paragraph:

import com.aspose.words.*;

public class ExtractRevisions {
    public static void main(String[] args) throws Exception {
        // Load the document
        Document doc = new Document("path/to/your/document.docx");

        // Access a specific paragraph (for example, the first paragraph)
        Paragraph paragraph = (Paragraph) doc.getFirstSection().getBody().getParagraphs().get(0);

        // Retrieve revisions for the specific paragraph
        for (Revision revision : paragraph.getRevisions()) {
            System.out.println("Revision Type: " + revision.getRevisionType());
            System.out.println("Author: " + revision.getAuthor());
            System.out.println("Date: " + revision.getDateTime());
            System.out.println("Text: " + revision.getParentNode().getText());
        }
    }
}

In this example, we load a document, access the first paragraph, and then iterate through its revisions, printing out details such as the type of revision, the author, and the date.

This approach allows you to focus on revisions specific to a node, providing a more granular view of changes made to your document.

For more detailed information on handling revisions, you can refer to the comprehensive guide on document revisions in Aspose.Words for Java here.

Sources:
[1]: The Ultimate Guide to Document Revision | Aspose.Words Java Document …

@ashu_agrawal_sirionlabs_com You can use Range.Revisions property to get revision applied to a particular node.