Spaces Shown as Insert Revisions After Deleting Whole Paragraph and Accept revision before compare in Word Comparison

When we upload an input file for Aspose Word comparison and accept all revisions before comparing, if a whole paragraph is deleted, it removes only the text and leaves the spaces behind. The issue arises when we download the compared file, as these spaces are shown as insert revisions.

Is there any solution for this?
I am attaching snapshots and files for your reference.
BaseFile.docx (53.6 KB)
CompareFileAspose.docx (74.0 KB)
InputFile.docx (45.6 KB)
InputFileAfterAcceptingRevision.docx (38.9 KB)
InputFileBeforeAcceptingRevision.docx (39.5 KB)

Input file:
InputFile.docx (45.6 KB)

Input File while we load in aspose(var docA = new Aspose.Words.Document(doc2)):
InputFileBeforeAcceptingRevision.docx (39.5 KB)

After Accepting Revision(docA.AcceptAllRevisions()):
InputFileAfterAcceptingRevision.docx (38.9 KB)

Base File:
BaseFile.docx (53.6 KB)

Compared Aspose File:
CompareFileAspose.docx (74.0 KB)

@ttinwala The question has been already answered in another your thread:
https://forum.aspose.com/t/aspose-word-adding-extra-space-after-deleted-content/290519

1 Like

Is there any way to remove the extra spaces when using AcceptAllRevisions(), specifically in cases where a deleted paragraph has no text left after accepting the revisions?

@ttinwala In your document only content of the paragraph is removed by revision, but not the whole paragraph. You can see this by showing formatting marks:

So Aspose.Words behavior is correct and expected. You can try using the following code to remove such paragraphs:

Document doc = new Document(@"C:\Temp\in.docx");

foreach (Paragraph p in doc.GetChildNodes(NodeType.Paragraph, true))
{
    if (p.Range.Revisions.Count > 0)
    {
        p.Range.Revisions.AcceptAll();
        if (!p.HasChildNodes && p.ParentNode != null)
            p.Remove();
    }
}

doc.Save(@"C:\Temp\out.docx");
1 Like

Thank you, @alexey.noskov , for your help…

1 Like