Get Page Number and Date Values of each Revision Line Item in Word Document using Java

Hi,
I am using RevisionGroupCollection for extracting Insertion, Deletion, and Formatted contents. This is giving the correct results. But the problem is that the api does not have method to get the page number of each line items and date value also not coming for each items.

Document doc = new Document(documentName);
doc.getLayoutOptions().getRevisionOptions().setShowRevisionMarks(false);
doc.getLayoutOptions().getRevisionOptions().setShowRevisionBars(false);
doc.getLayoutOptions().getRevisionOptions().setShowOriginalRevision(false);

RevisionCollection revisionCollection = doc.getRevisions();
RevisionGroupCollection revGroupCollection = revisionCollection.getGroups();
for (RevisionGroup revisionGroup : (Iterable) revGroupCollection) {
String revisonAuthor = revisionGroup.getAuthor();
int revisionModeInt = revisionGroup.getRevisionType();
String text = revisionGroup.getText().trim();
String revisionMode = “”;
if(revisionModeInt == 0 ){
revisionMode = “INSERTION”;
}else if(revisionModeInt == 1 ){
revisionMode = “DELETION”;
}else if(revisionModeInt == 2 ){
revisionMode = “FORMAT_CHANGE”;

}	

}

How to get the date value and page number for each iteration?

Also i am expecting this aspose api output should match the MS-Word revision panel output.

Please provide a code solution for fixing this issue.

@HAREEM_HCL_COM,

Please ZIP and upload your simplified input Word document and a screenshot highlighting the desired areas (you want to get date and page number values of) here for testing. We will then investigate the scenario on our end and provide you more information.

Hi Aspose Team,

I want to read all the comments and track changes(Insertion, Deletion, Format_change) values from word documents. Whatever i have seen in the Word document from MS-Office application, the same number of revisions and values(see.reference1.png) from Aspose output. But i am not getting the same results from aspose api.
sample.zip (1.7 MB)

If i use RevisionGroupCollection, i am getting the results which is similar to results in Ms-Office viewer. But the challenge is to get the pageNumber and date value for each insertion/deletion/format_change entries. (see.reference2.png)

If i use Revision, i am able to data with pagenumbers and date value, but it is generating more results from the expected results(219 revisions)

Please provide good soultion to read all comments and track changes(Insertion, Deletion, Format_change) values with PageNumber, Date, Author Name, Text, and Revision Type from word documents with correct count

Please find the attached(sample.zip) sample docx and screenshots for your references.

@HAREEM_HCL_COM,

We have logged your requirement in our issue tracking system. Your ticket number is WORDSNET-20233. We will further look into the details of this requirement and will keep you updated on the status of the linked issue. Sorry for any inconvenience.

Team, Any updates on ticket number WORDSNET-20233

@HAREEM_HCL_COM,

Your issue (WORDSNET-20233) is currently ‘pending for analysis’ and is in the queue. We will inform you via this thread as soon as we have a solution for this or any further updates may be available. We apologize for any inconvenience.

Any updates on my query? Because i am waiting quite more than 5days and its high priority activity in current project. Team, please provide the time line to fix this Problem Request.

@HAREEM_HCL_COM,

We have logged your concerns in our issue tracking system.

But I am afraid, your issue is currently pending for analysis and is in the queue. There are no estimates available at the moment. Once the analysis of this issue is completed, we may then be able to calculate and share the ETA of this issue with you. We apologize for your inconvenience.

I don’t know what is the size of your issue queue. So please think this pain point from customer end. Please take it as a high priority or blocker issue and do the analysis quickly and share ETA.

@HAREEM_HCL_COM,

Please check the following details:

  1. DateTime

RevisionGroup contains a list of revision which can have different Dates. I am afraid, we cannot implement RevisionGroup.Date as you requested because group might contain revisions with different Dates. Maybe you will be satisfied with DateTime of the first revision, or maybe DateTime range. Please check the following code that demonstrates how to get DateTime of the very first and very last revision…

RevisionCollection revisions = doc.getRevisions();
RevisionGroupCollection groups = doc.getRevisions().getGroups();

Map<RevisionGroup, List<Revision>> revisionDictionary = new HashMap<RevisionGroup, List<Revision>>();
for (Revision revision : revisions) {
    if (revision.getGroup() != null) {
        if (revisionDictionary.containsKey(revision.getGroup())) {
            List<Revision> existedList = revisionDictionary.get(revision.getGroup());
            existedList.add(revision);
        } else {
            List<Revision> newList = new ArrayList<Revision>();
            newList.add(revision);
            revisionDictionary.put(revision.getGroup(), newList);
        }
    }
}

for (RevisionGroup group : groups) {
    String authorName = group.getAuthor();
    String revisionType = RevisionType.getName(group.getRevisionType());
    String text = group.getText();

    Date minRevisionDate = new Date(Long.MAX_VALUE);
    Date maxRevisionDate = new Date(Long.MIN_VALUE);

    // //some groups might have no revisions
    if (revisionDictionary.containsKey(group)) {
        List<Revision> groupRevisions = revisionDictionary.get(group);

        for (Revision revision : groupRevisions) {
            if (revision.getDateTime().compareTo(maxRevisionDate) > 0)
                maxRevisionDate = revision.getDateTime();

            if (revision.getDateTime().compareTo(minRevisionDate) < 0)
                minRevisionDate = revision.getDateTime();
        }
    }
}
  1. Page Number

Page number depends on document properties - page size, margins, etc. I am afraid, we cannot provide a ‘universal’ page-number for the revision or comment.

  1. Comments

Please check the following code:

NodeCollection comments = doc.getChildNodes(NodeType.COMMENT, true);
for (Comment comment : (Iterable<Comment>) comments) {
    Date dateTime = comment.getDateTime();
    String author = comment.getAuthor();
    String text = comment.getText();
}

Hope, this helps.

@HAREEM_HCL_COM,

Regarding WORDSNET-20233, it is to update you that we have completed the work on this issue and concluded to close this issue with “Not a Bug” status. Please see my previous posts for details.