No result when comparing PDFs with GroupDocs.Comparison for Java

I’m testing out the comparison functionality with GroupDocs.Comparison specifically when comparing PDFs. I put together a quick test and the Words comparison works fine but the PDF comparison does not generate an error but also does not produce a document. Is there something I’m missing? I’m following the examples and these are pretty trivial tests. You can run the test by just running:

./gradlew run

Hi Cking,

Thanks for posting the query.

I’m following the examples

Can you please tell us, which example project you are using? Did you get example project from here?

Best Wishes

Yes, if you click the link you provided and go into the Examples and the file PdfDocumentsComparison.java you will see a method:

/*
 * Comparing two pdf documents from streams, with settings and saving output
 * to a resultant file
 */
public static void ComparePdfFromStreamToFile(String sourceFile, String targetFile) throws Throwable {
    //ExStart:ComparePdfFromStreamToFile
    // Create two streams of textFiles
    InputStream sourceStream = Utilities.sourceStream(sourceFile);
    InputStream targetStream = Utilities.targetStream(targetFile);
    // Create instance of GroupDocs.Comparison.Comparison and call method
    // Compare.
    Comparison comparison = new Comparison();
    InputStream result = comparison.compare(sourceStream, targetStream, Utilities.outputFileName(extension),
            ComparisonType.Pdf, new PdfComparisonSettings());
    //ExEnd:ComparePdfFromStreamToFile
}

That is functionally identical to the method I provided. The code example (TestRunner.java) is only 40 lines long so not much to review, but the method:

public static void comparePdf() throws Exception {
    Comparison comp = new Comparison();
    InputStream oldDoc = TestRunner.class.getResourceAsStream("original.pdf");
    InputStream newDoc = TestRunner.class.getResourceAsStream("updated.pdf");

    PdfComparisonSettings settings = new PdfComparisonSettings();

    comp.compare(oldDoc, newDoc, "result.pdf", ComparisonType.Pdf, settings);
}

Is equivalent in all ways to the one from the examples.


Hi Cking,

We are able to reproduce this issue at our end as well (output Pdf document is not generated with gradle). Hence, we have logged it in our internal issue tracking system. As we get any update from the concerned team, we will apprise you.

Kind Regards

Any updates here? These issues are currently holding up our purchasing decision so I’m just trying to get an update on if and when this may be fixed.

Hi Cking,


We have asked about the progress/state of this issue from the concerned team. Hence, as we get any update from them, we will notify you. Please stay tuned.
We appreciate your patience.

Many Thanks