Compare results formatting changes (in HTML)

Comparing Result formatting changes.

I am comparing two HTML’s . And i want to change formatting of the Result HTML (that i am getting through the compare API)

  1. The result html is completely changed from the given input html. I mean you have added span tag and some styles to the html. I only want to put “<ins” and "<del " tag to the changed text. Is it possible ?
  2. I want to give my custom styling to the text for removed and inserted text like I want to give custom background color and strikethrough the text.

Can i do that. ?

  1. For Image comparison (In my case - svg) , sometimes the output is not correct ( I have compared two different iamges , Sometimes , it returns both images and sometimes only single image).

Using JAVA Api for compare

@chiraggupta629

Unfortunately, this is not possible. Upon loading HTML document Aspose.Words reads it into the DOM which is designed to work with MS Word documents. So after HTML->Aspose.Words DOM->HTML roundtrip is is not possible to preserve the original HTML document structure.

If you save your document to fixed page formats, like PDF, XPS, HtmlFixed, you can use LayoutOptions.RevisionOptions to specify revisions colors and other formatting. Unfortunately, there is no such ability when you output to flow HTML format.

Could you please attach your sample documents here for testing? We will check the issue and provide you more information. It is difficult to say what is the different without your documents. In most cases Aspose.Words comparison algorithm mimics MS Word comparison feature. So you can check this on your side and see how MS Word behaves.

Hello @alexey.noskov

I have attached both HTML input1.html and input2.html , and the result HTML.

Code used to compare -

Document docA = new Document("Input1.html");
Document docB = new Document("Input2.html");

HtmlFixedSaveOptions options = new HtmlFixedSaveOptions();
options.setExportEmbeddedCss(true);
options.setExportEmbeddedFonts(true);
options.setExportEmbeddedImages(true);
options.setExportEmbeddedSvg(true);

// There should be no revisions before comparison.
docA.acceptAllRevisions();
docB.acceptAllRevisions();

CompareOptions cmpOptions = new CompareOptions();
cmpOptions.setIgnoreFormatting(false);

docA.compare(docB, "Author", new Date(), cmpOptions);
docA.save("Output_withHtmlfixed.html", options);

Image.zip (41.6 KB)

In the output html , one image has been removed by the compare API.

@chiraggupta629 Thank you for additional information. I have managed to reproduce the problem on my side. For a sake of correction it has been logged as WORDSNET-24565. We will keep you informed and let you know once it is resolved.

The issues you have found earlier (filed as WORDSNET-24565) have been fixed in this Aspose.Words for Java 22.12 update.