Document Comparison producing No Content in Document

Hello,

I tried comparing two docx documents using Aspose library in .NET and they worked by producing an output document which contained revisions after comparing input docx 1 and 2 but the same thing does not work in Java. It generates a docx but the content is empty.

Source code:

public int compareDocuments(String expectedFile, String actualFile, Map<String, String> testData) throws Exception {
        
    Document expectedDoc = new Document(expectedFile);
    Document actualDoc = new Document(actualFile);
    int compResult = 0;
    String comparedfileName = expectedFile;
    String comparedDocPath =System.getProperty("user.dir")+"\\ComparedDocs";
        
    String []fileNames = comparedfileName.split("\\\\");
    System.out.println("Compared File Name: "+fileNames[9]);
        
    try{
        CompareOptions options = new CompareOptions();
        options.setIgnoreFormatting(Boolean.valueOf(testData.get("Format")));
        options.setIgnoreHeadersAndFooters(Boolean.valueOf(testData.get("Header")));
        options.setIgnoreCaseChanges(Boolean.valueOf(testData.get("Case")));
        options.setIgnoreTables(Boolean.valueOf(testData.get("Tables")));
        options.setIgnoreFields(Boolean.valueOf(testData.get("Fields")));
        options.setIgnoreComments(Boolean.valueOf(testData.get("Comments")));
        options.setIgnoreTextboxes(Boolean.valueOf(testData.get("Textbox")));
        options.setIgnoreFootnotes(Boolean.valueOf(testData.get("Footnotes")));
        options.setTarget(ComparisonTargetType.NEW);

        // Compare documents
        expectedDoc.compare(actualDoc, "author", new Date(), options);

        //Save Compared document
        //expectedDoc.save(comparedDocPath+"\\"+fileNames[9],SaveFormat.DOCX );
        actualDoc.save(comparedDocPath+"\\"+fileNames[9]);

        // Actual Revision count should be less then and equal to Expected Revision count
        if(expectedDoc.getRevisions().getCount() <= Integer.valueOf(testData.get("ExpectedRev"))){
            compResult = Integer.valueOf(testData.get("ExpectedRev"));
        }
        else {
            compResult = expectedDoc.getRevisions().getCount();
        }
    }
    catch(Exception e){
    }
    // return the revision count
    return compResult;
}

Input Doc 1: TC-4426.docx (443.5 KB)

Input Doc 2TC-4426.docx (170.2 KB)

Output Doc: TC-4426.docx (16.0 KB)

@sujaiswal On my side the following code throws an exception upon comparing the attached documents:

Document in1 = new Document("C:\\Temp\\in1.docx");
Document in2 = new Document("C:\\Temp\\in2.docx");

in1.compare(in2, "author", new Date());
    
in1.save("C:\\Temp\\out.docx");

We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-25819

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Regarding the original issue you have reported, could you please let us know what parameters are set in CompareOptions on your side? We will check the issue once again and provide you more information.

@alexey.noskov, everything in compare options is set to false. We are checking every area for revision in a word doc.
As for the paid support, we already have a paid Aspose.Total license.

@sujaiswal With the following code I get the same exception on my side:

Document in1 = new Document("C:\\Temp\\in1.docx");
Document in2 = new Document("C:\\Temp\\in2.docx");

CompareOptions options = new CompareOptions();
options.setIgnoreFormatting(false);
options.setIgnoreHeadersAndFooters(false);
options.setIgnoreCaseChanges(false);
options.setIgnoreTables(false);
options.setIgnoreFields(false);
options.setIgnoreComments(false);
options.setIgnoreTextboxes(false);
options.setIgnoreFootnotes(false);
options.setTarget(ComparisonTargetType.NEW);

in1.compare(in2, "author", new Date(), options);

in1.save("C:\\Temp\\out.docx");

So looks like this is the same problem. We will investigate it deeper and provide you more information.