Comparing two PDF files returns null in Java

I see many similar topics here, but no conslusive answer.

To reproduce:

  • Clone https://github.com/groupdocs-comparison/GroupDocs.Comparison-for-Java.git

  • Modify Examples/GroupDocs.Comparison.Examples.Java/src/main/java/com/groupdocs/comparison/examples/MainClass.java to uncomment one line: PdfDocumentsComparision.ComparePdfFromStreamToFile("source.pdf", "target.pdf");

  • In Examples/GroupDocs.Comparison.Examples.Java run mvn package.

  • From command line, execute: java -cp "target/classes:$HOME/.m2/repository/com/groupdocs/groupdocs-comparison/18.6.3/groupdocs-comparison-18.6.3.jar" com.groupdocs.comparison.examples.MainClass.

Result:
Exception in thread “main” java.lang.NullPointerException
at com.groupdocs.comparison.examples.PdfDocumentsComparision.ComparePdfFromStreamToFile(PdfDocumentsComparision.java:28)
at com.groupdocs.comparison.examples.MainClass.main(MainClass.java:173)

The NPE happens because comparison.compare(…) returns null.

The error happens with any PDFs I tested with. No matter if I run the examples (as above), my custom test, from command line or from Idea. No matter if without a license or with one (testing). Other filetypes (Word, PowerPoint etc.) work.

@doublep,

Thanks for taking interest in GroupDocs.Comparison for Java and posting your concerns.

We investigated this scenario at our end and noticed that if license is not properly loaded or applied java.lang.NullPointerException occurs.

If you are applying license, make sure it is properly applied/loaded and it is not expired.

Please note, API returns only 4 elements from every collection without a license. So it can not get necessary object model to build a document. That is why exception happens in PDF case.

Can you please share output of Word comparison?
If your license is not applied properly, you will see a evaluation tag in the output of such documents.

We investigated this scenario at our end and noticed that if license is not properly loaded or applied java.lang.NullPointerException occurs.

How about throwing an exception with explanation of what’s wrong instead of failing silently? This way each next user wouldn’t have to guess why this … doesn’t work and if he should just use something else. Not to mention that it appears to be not license-related in this case.

If you are applying license, make sure it is properly applied/loaded and it is not expired.

It writes “License is validated” to stderr.

Can you please share output of Word comparison? If your license is not applied properly, you will see a evaluation tag in the output of such documents.

I can see no evaluation tag: https://quickfileshare.org/Th6/output.docx

@doublep,

Thanks for the clarification. We are investigating this issue at our end. Your investigation ticket ID is COMPARISONJAVA-447. As we have any update on it, we shall notify you. We’ll appreciate your patience in this regard.

@doublep,

Your issue COMPARISONJAVA-447 will be resolved in upcoming release of the API. We’ll update you as we have any further update.

@doublep,

Your reported issue is now fixed. Please integrate latest release of the API in your project and share your feedback.