Aspose Track changes on word document

Hi,

My requirement is to track the content of word document. In detail, i want to open the document in div or any content place holder and would be able to edit the text. As we have in msword, if i click on track changes and editing text font color in red and deleted text in strikes.So can i do the functionality using aspose.words.

I found only the accept and revert changes in aspose.words api. This is useful once i complete the above functionality is done.

Thanks& regards,
rathna kumar thota.

Hi Rathna,

Thanks for your inquiry. Following public methods were added to start/stop automatic revision tracking.

Document.StartTrackRevisions(string author, DateTime dateTime);
Document.StartTrackRevisions(string author);
Document.StopTrackRevisions();

Note that these methods has no correlation this Document.TrackRevisions property so setting this property has no effect to Aspose.Words. You should explicitly call StartTrackRevision method to start automatically revision tracking in Aspose.Words.

Currently formatting changes are not tracked.

There are few limitation in current implementation. Revision tracking is suspended (node changes are not tracked) during the following methods:

  1. field updating - Document.UpdateFields() method
  2. field insertion - DocumentBuilder.InsertField() method
  3. text replace - Range.Replace() method
  4. mail merge - MailMerge.Execute() method.

Use case:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.Writeln("hello"); // this is not tracked

doc.StartTrackRevisions("user1");
builder.Writeln("message from user1"); // this is marked as inserted by user1

doc.StartTrackRevisions("user2");
builder.Writeln("comment from user2"); // this is marked as inserted by user2

doc.StartTrackRevisions("user3", DateTime.Now);
doc.RemoveAllChildren(); // both paragraphs inserted above are marked as deleted

doc.StopTrackRevisions();

builder.Writeln("let’s start it all over"); // this is not marked because tracking has been stopped.

I hope, this helps.

Best regards,

Hi Awais,

Sorry for making you little confuse.

The code you provided is helpful only when ever user know the text that to be tracked.
But in my case, i have content place holder of document filled and track changes button.As user can do any change in document runtime.

In detail the requirement is Interface for track changes.Interface should have content with track changes button. When ever user click on track changes, automatically the editing text in content should change to red and deleted text should strike instead delete. The color change and strike lines should happen in runtime as we have in wsword.Simply, Replica of MSWord Track changes.

Regards & thanks,
rathna kumar thota.

Hi,

Could you please reply for the previous mail.

Regards,
rathna kumar thota.

Hi Rathna,

Thanks for your inquiry. You should note that Aspose.Words is a class library for working with Word documents programmatically. It provides programmatic access through a rich API to all document elements and formatting that allows to create, modify, extract, copy, split, join, and replace document content without using Microsoft Word. However, It does not provide any graphic user interface for editing/viewing documents. I am afraid, currently we do not have plans to create such editor.

Best regards,

Hi awais,

Thanks for the reply.

As per my understanding the aspose.words class library can be able to get list of tracked changes for the document.
Also i have another requirement to export the document with tracked changes.

Please send me sample code to list out the tracked changes of document and export document without loosing its track changes.Simply to say, import document track changes and export document with track changes.

Hope you understand my query. Please reply me asap.

Regards,
rathna kumar thota.

Hi Rathna,

Thanks for your inquiry. Yes, you can get list of tracked changes for the document using the Document.TrackRevisions property. Also, when you import document into another document using the following code, revisions will remain be preserved in final document.

Document doc1 = new Document(MyDir + @"Doc1.docx");
Document doc2 = new Document(MyDir + @"Doc2.docx");
doc2.AppendDocument(doc1, ImportFormatMode.KeepSourceFormatting);
doc2.Save(MyDir + @"out.docx");

I hope, this helps.

Best regards,

Hi awais,

Thanks for the reply.

I hope the code is helpful for future developments.Right now ,i want to list out the track changes of section wise in a document.
In detail, if document has sections (sub headings) and each section has track changes.I need to get the list of track changes for particular section. So please send me the sample code for listing the track changes of document section wise.

Regards,
rathna kumar thota.

Hi Rathna,

Thanks for your inquiry. You can use the following sample code to build your work on:

foreach (Section sec in doc.Sections)
{
    ArrayList secRevisions = new ArrayList();
    foreach (Revision rev in doc.Revisions)
    {
        if (rev.ParentNode.GetAncestor(NodeType.Section) != null &&
        rev.ParentNode.GetAncestor(NodeType.Section) == sec)
        {
            secRevisions.Add(rev);
        }
    }
    // do something useful with collection of revisions per section
}

I hope, this helps.

Best regards,