Compare with numbering is not matching

Hello Support

I am trying to compare two rtf files, Please see attached zip NumberLoss.zip (30.5 KB)
with UCO as original file UCM as modified file UC-Word as word compare output and UC-AsposeOutput as Aspose output.
Code used is below, Please note that for deleted content and added content, we are looping through nodes and adding colour and style. This is because in RTF fromat deleted content is not seen as strikeout. For images and ole objects we are adding bookmarks and during rendering we are overlaying images.

Please open files using Wordpad and not MS Word to see the difference.
We need to get numbering similar to that of word output. Your help is much appreciated.

Thanks in advance


        string sAuthor = "";
        int i=0;
        int j=0;
		Document docOrg = new Document("D:\\Compare\\UCO.rtf");
		Document doc=new Document("D:\\Compare\\UCM.rtf"); 
                sAuthor = doc.BuiltInDocumentProperties["Author"].Value.ToString();

        if (sAuthor.Equals("", StringComparison.InvariantCultureIgnoreCase) == true)
        {
            doc.BuiltInDocumentProperties.Author = "System";
            docOrg.BuiltInDocumentProperties.Author = "System";
            sAuthor = doc.BuiltInDocumentProperties["Author"].Value.ToString();
        }

        Aspose.Words.CompareOptions options = new CompareOptions();
        options.IgnoreFormatting = true;
        options.IgnoreHeadersAndFooters = true;

        docOrg.LayoutOptions.RevisionOptions.ShowRevisionBalloons = false;
        docOrg.LayoutOptions.RevisionOptions.ShowOriginalRevision = true;
        docOrg.LayoutOptions.RevisionOptions.RevisedPropertiesColor =  Aspose.Words.Layout.RevisionColor.Green;
        docOrg.LayoutOptions.RevisionOptions.RevisedPropertiesEffect =  Aspose.Words.Layout.RevisionTextEffect.Underline;
        docOrg.LayoutOptions.RevisionOptions.InsertedTextColor = Aspose.Words.Layout.RevisionColor.Blue;
        docOrg.LayoutOptions.RevisionOptions.InsertedTextEffect = Aspose.Words.Layout.RevisionTextEffect.Underline;
        docOrg.LayoutOptions.RevisionOptions.DeletedTextColor = Aspose.Words.Layout.RevisionColor.Red;
        docOrg.LayoutOptions.RevisionOptions.DeletedTextEffect = Aspose.Words.Layout.RevisionTextEffect.StrikeThrough;

        
        docOrg.Compare(doc, sAuthor, DateTime.Now, options);

    	RtfSaveOptions rtfsvaeopt = new RtfSaveOptions();

    	rtfsvaeopt.UseAntiAliasing = true;
    	rtfsvaeopt.SaveFormat = SaveFormat.Rtf;
        DocumentBuilder builder = new DocumentBuilder(docOrg);

        foreach (Node nod in docOrg.GetChildNodes(NodeType.Any, true))
        {
            if (nod.NodeType == NodeType.Paragraph)
            {
                Paragraph paraNode = (Paragraph)nod;

                foreach (Run run in paraNode.GetChildNodes(NodeType.Run, true))
                {
                    if (run.IsDeleteRevision)
                    {
                        run.Font.Color = Color.Red;
                        run.Font.StrikeThrough = true;
                    }

                    if (run.IsInsertRevision)
                    {
                        run.Font.Color = Color.Blue;
                        run.Font.UnderlineColor = Color.Blue;
                        run.Font.Underline = Underline.Single;
                    }

                    if (run.IsFormatRevision)
                    {
                        //run.Font.ClearFormatting();
                        run.Font.Color = Color.Green;
                        run.Font.UnderlineColor = Color.Green;
                        run.Font.Underline = Underline.Single;
                    }
                }
            }

            if (nod.NodeType == NodeType.Cell)
            {
                Cell cellNode = (Cell)nod;

                if (cellNode.FirstParagraph.IsDeleteRevision)
                {
                    cellNode.CellFormat.Shading.BackgroundPatternColor = Color.Red;
                }

                if (cellNode.FirstParagraph.IsInsertRevision)
                {
                    cellNode.CellFormat.Shading.BackgroundPatternColor = Color.Blue;
                }

                foreach (Run run in cellNode.GetChildNodes(NodeType.Run, true))
                {
                    if (run.IsDeleteRevision)
                    {
                        run.Font.Color = Color.Red;
                        run.Font.StrikeThrough = true;
                        //cellNode.CellFormat.Shading.BackgroundPatternColor = Color.White;
                    }

                    if (run.IsInsertRevision)
                    {
                        run.Font.Color = Color.Blue;
						run.Font.UnderlineColor = Color.Blue;
                        run.Font.Underline = Underline.Single;
                        //cellNode.CellFormat.Shading.BackgroundPatternColor = Color.White;
                    }

                    if (run.IsFormatRevision)
                    {
                       	//run.Font.ClearFormatting();
                    	run.Font.UnderlineColor = Color.Green;
                        run.Font.Underline = Underline.Single;
                        //cellNode.CellFormat.Shading.BackgroundPatternColor = Color.White;
                    }
                }
            }

            if (nod.NodeType == NodeType.Shape)
            {
                Shape shapeNode = (Shape)nod;

                if (shapeNode.IsDeleteRevision)
                {
                	builder.MoveTo(shapeNode);
					builder.StartBookmark("BK_DD" + i.ToString());
					builder.EndBookmark("BK_DD" + i.ToString());
					i=i+1;
                	//shapeNode.Font.ClearFormatting();
                    //shapeNode.Font.Color = Color.Red;
                    //shapeNode.Font.StrikeThrough = true;
                }

                if (shapeNode.IsInsertRevision)
                {
                	builder.MoveTo(shapeNode);
					builder.StartBookmark("BK_DI" + i.ToString());
					builder.EndBookmark("BK_DI" + i.ToString());
					j=j+1;

                	//shapeNode.Font.ClearFormatting();
                    //shapeNode.Font.Color = Color.Blue;
                    //shapeNode.Font.Underline = Underline.Single;
                    //shapeNode.RemoveAllChildren();
                }
            }
        }
    	docOrg.Save("D:\\Compare\\UC-AsposeOutput.rtf", rtfsvaeopt);			
	}

Regards
Mandar

@mandar_limaye,

Thanks for your inquiry. We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16462. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

Hello Tahir,

Is there some work around to resolve this with some additional coding or regex replacement?

Thanks in advance

Mandar

@mandar_limaye,

Thanks for your inquiry. Please note that Aspose.Words mimics the behavior of MS Word. The output document shows correct list numbering when it is opened in MS Word. Unfortunately, there is no workaround for this issue. We will inform you via this forum thread once there is any update available on this issue. Thanks for your patience.

Hello Tahir,
Thanks for update. I have further checked on this when I save compare as docx and then save it as rtf from word it is same as word output. So issue seems to be while converting docx to rtf.
I have checked rtf itself and there is reasonable change. I even tried to to some regex on raw rtf itself but found it not practical.

Regards
Mandar

@mandar_limaye,

Thanks for sharing the detail. We have logged this detail in our issue tracking system. We will inform you via this forum thread once there is any update available on this issue. Please let us know if you have any more queries.

The issues you have found earlier (filed as WORDSNET-16462) have been fixed in this Aspose.Words for .NET 19.3 update and this Aspose.Words for Java 19.3 update.