Aspose words C# Issue with Track changes with Replace Text(striked out shows after the new text)

I am trying to use StartTrackRevisions with Replace text in word doc.
Code sample is:

document.StartTrackRevisions("Changes");
para.Range.Replace("Soft Costs", "abcd", options);
document.Save(filepath)

But the track change history behavior is different then manual process in word document.
The added text is showing prior to the strikeout/removed text.

Idealy it should show strikeout first and then the new text like below:

Is this fixed behavior when we edit the doc file with Aspose or is there a way to correct this?

@mudit.mishra
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-26924

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

The issues you have found earlier (filed as WORDSNET-26924) have been fixed in this Aspose.Words for .NET 24.7 update also available on NuGet.

Hi @aspose.notifier @alexey.noskov
I tried with the updated Aspose.Words version as suggested.
But, Now I am facing below issue with TrackRevisions and not even able to use the functionality:

Below code works fine:
Document document = new Document(filePath);
document.Range.Replace(“text1”,“text2”);
document.Save(outputPath);

Below code gives error:
Document document = new Document(filePath);
document.StartTrackRevisions(“Tracking”);
document.Range.Replace(“text1”,“text2”);
document.Save(outputPath);

error msg:

‘document.Save(outputPath)’ threw an exception of type ‘System.ArgumentException’
Data: {System.Collections.ListDictionaryInternal}
HResult: -2147024809
HelpLink: null
InnerException: null
Message: “Cannot insert a node of this type at this location.”
ParamName: null
Source: “Aspose.Words”
StackTrace: " at Aspose.Words.CompositeNode.\u0005[T](T \u0002, Node \b, Boolean \u0005)\r\n at \u000f .\u0006(Document \u0002)\r\n— End of stack trace from previous location —\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at \u0005 .\b(Object \u0002)\r\n at \u0005 .\b(MethodBase \u0002, Boolean \b)\r\n at \u0005 .\u0006 ()\r\n at \u0005 .\b(Boolean \u0002)\r\n— End of stack trace from previous location —\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at \u0005 .\b(Object \u0002)\r\n at \u0005 .\u000e ()\r\n at \u0005 .\u0002(Object \u0002, UInt32 \b)\r\n at \u0005 .\b(Boolean \u0002)\r\n at \u0005 .\u0002(Object[] \u0002, Type[] \b, Type[] \u0005, Object[] \u0006)\r\n at \u0005 .\u0002(Int32 \u0002, Type[] \b, Type[] \u0005, Boolean \u0006)\r\n at \u0005 .\u0002 (\u0005 \u0002, \u0005 \b)\r\n at \u0005 .\u0006 ()\r\n at \u0005 .\b(Boolean \u0002)\r\n— End of stack trace from previous location —\r\n a
t System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at \u0005 .\b(Object \u0002)\r\n at \u0005 .\u000e ()\r\n at \u0005 .\u0002(Object \u0002, UInt32 \b)\r\n at \u0005 .\b(Boolean \u0002)\r\n at \u0005 .\u0002(Object[] \u0002, Type[] \b, Type[] \u0005, Object[] \u0006)\r\n at \u000f .\u0002(Document \u0002)\r\n at Aspose.Words.Document.\u0002(Stream \u0002, String \b, SaveOptions \u0005)\r\n at Aspose.Words.Document.Save(String fileName)"
TargetSite: {T [T](T, Aspose.Words.Node, Boolean)}
document.Save(outputPath);
{Aspose.Words.Saving.SaveOutputParameters}
ContentType: “application/vnd.openxmlformats-officedocument.wordprocessingml.document”

Please suggest if there is any change in the track changes process and what I am missing.

@mudit.mishra Could you please provide you document for testing?

You can try with any docx document.
I tried with attached sample document too. The error is coming at the line to save the output document.

tobeEdited.docx (19.3 KB)

document = new Document(“/tobeEdited.docx”);
document.Range.Replace(“sample”,“sample2”);
document.StartTrackRevisions(“CCMC”);
document.Save(“output.docx”);

Also, after updating I am trying with evaluation copy only as it will need latest license version. But I have tried with same on older api versions this did not created any issue before.

@mudit.mishra Unfortunately, I can’t reproduce the problem on my side with the latest version. Please update your version of Aspose.Words if you are using an older version.

@vyacheslav.deryushev
Could you please a sample code for Replacing text along with Track changes enabled, That worked for you, So I can take reference?

Also, could the issue be due to the evaluation version I am using?

@mudit.mishra I have used both versions of the code you provided, and there are no exceptions in this code. The evaluation version has limitations, so yes, that may be true. If you would like to test Aspose.Words without evaluation version limitations, you can request a free 30-days temporary license .

Please see our documentation to learn more about licensing: