Compare: formatting changes lost when saved as html

We are using Aspose.Words 22.7 to create diffs between different versions of docx files. The diffs are saved as html. Find attached a reduced test case. In Testfile_v2.docx the text has be been formatted as strike through. Running the program creates two files: Diff.docx and Diff.html. Diff.docx shows the formatting change. Diff.html contains no indication of any change and shows the original version. The problem affects other formatting changes as well, but this one is especially important.

FormatDiffBug.zip (49.8 KB)

@IBP Thank you for reporting the problem to us. But this cannot be considered as a bug, since MS Word comparison works just like MS Word comparison and differences are marked with revisions. Since HTML format does not support format revisions, there is no good way to export such revisions to HTML.
If you need to preserve revisions only for visual representation, you can consider saving the resulting document as HtmlFixed. In this case the document will looks exactly as it looks in MS Word:

HtmlFixedSaveOptions options = new HtmlFixedSaveOptions()
{
    ExportEmbeddedCss = true,
    ExportEmbeddedFonts = true,
    ExportEmbeddedImages = true,
    ExportEmbeddedSvg = true
};

Document document_v1 = new Document(@"C:\Temp\Testfile_v1.docx");
Document document_v2 = new Document(@"C:\Temp\Testfile_v2.docx");

document_v1.Compare(document_v2, "author", DateTime.Now, new CompareOptions
{
    IgnoreFormatting = false
});

document_v1.Save(@"C:\Temp\Diff.html", options);
document_v1.Save(@"C:\Temp\Diff.docx");

Hello @alexey.noskov ,

I am havig the save problem. I am comparing two HTML files , while exporting it to the DOCX , I can see the formatting changes ( Rich text formatting ) , But exporting in HTMl the formatting and revision history was lost . I have implemented the solution given by you . Now i can see the formatting in HTML. But my revision history is coming empty and if i export as .docx , it produces the accurate result with revision history.

I am using aspose-words-22.9 with OpenJDK - jdk-8.0.232.09-openj9.

docx.png (6.7 KB)
revisionHistoryLost.zip (1.1 KB)
HTML.png (3.0 KB)

@chiraggupta629 It looks like you need to set ShowInBalloons.FORMAT_AND_DELETE in RevisionOptions. Please try using code like the floowing:

docA.compare(docB, "Author", new Date(), cmpOptions);

docA.getLayoutOptions().getRevisionOptions().setShowInBalloons(ShowInBalloons.FORMAT_AND_DELETE);

docA.save("C:\\Temp\\Output.html", options);
docA.save("C:\\Temp\\Output.docx");