Free Support Forum - aspose.com

Compare in Aspose Words for Java

How does the Aspose compare work with Aspose.words for Java?
Will we be able to see the compare as shown in the URL: https://blog.aspose.com/2015/03/02/compare-microsoft-word-documents/

But this is stating as only for .Net and no mention is provided for .java. Can you please explain.
Thanks,
Kundana.

@Kundana,

Thanks for your inquiry. Please refer to the following article about comparing document using Aspose.Words for Java.
How to Compare Two Word Documents

@tahir.manzoor
Thanks for your quick reply. We tried this but we are not able to see any output generated let alone see the differences as shown in the link.
We are not sure what we missed. We can still work on this but I want to understand if the output look and feel of the comparison will be same like how its shown in the link for Aspose compare for .Net. https://blog.aspose.com/2015/03/02/compare-microsoft-word-documents/

Kindly confirm.
Thanks,
Kundana.

@Kundana,

Thanks for your inquiry. Aspose.Words for Java is just a class library and with it you can programmatically generate, modify, convert, render and print documents without utilizing Microsoft Word®. So, it does not offer any UI or web control for performing these document processing tasks on web pages.

Please use the following code example to compare documents. Open the output document in MS Word to see the difference. This code example also saves the document pages into images. You can use these images into your application to view them.

Document docA = new Document(MyDir + "DocumentA.docx");
Document docB = new Document(MyDir + "DocumentB.docx");
docA.compare(docB, "user", new Date()); // docA now contains changes as revisions
docA.save(MyDir + "output.docx");

// Save the document to images
docA.getLayoutOptions().getRevisionOptions().setDeletedTextColor(RevisionColor.RED);
docA.getLayoutOptions().getRevisionOptions().setInsertedTextColor(RevisionColor.GREEN);
int count = docA.getPageCount();
for (int i = 0; i < count; i++)
{
    ImageSaveOptions opt = new ImageSaveOptions(SaveFormat.PNG);
    opt.setPageIndex(i);
    opt.setPageCount(1);
    docA.save(MyDir + "out_" + i + ".png", opt);
}