Compare two PDF files, Null pointer Exception using Java

Hi,

Even i am getting same Null pointer Exception while comparing 2 PDF files. My Environment details are as below.

OS : Windows 10 64 bit
JDK : jdk1.8.0_112
IDE : Eclipse neon (4.6.0)


This Topic is created by atirtahir3 using Email to Topic tool.

@ashwin1483,

Can you please confirm if you can compare Word files without any issue? Also, specify API version that you are using.

i have same problem as above, output return null when compare 2 files pdf. i used groupdocs.comparison ver 18.6.3. Comparing with docx, xlsx files without any issue. Hope to help.

1 Like

@ashwin1483,

We cannot reproduce this issue at our end using version 19.3. See this screenshot - comparison.JPG (202.2 KB) and output - output.pdf (101.4 KB).
Can you please add GroupDocs.Comparison for Java 19.3 JAR file as an external library - external jar.JPG (53.2 KB) and remove its dependency from pom.xml, then share your feedback with us.

@ashwin1483,

Can you please confirm if you can compare attached files successfully?
testtarget.pdf (2.4 KB)
testsource.pdf (2.1 KB)
Make sure you have Calibri and Times New Roman fonts installed in your environment.

@atirtahir3,
output.pdf (123.9 KB)

Sorry for the delayed response, i tested with file provided by you and its working fine attached is the output.pdf file. But i get same execption as below while trying with other pdf’s.

Exception in thread “main” java.lang.NullPointerException
at com.pdfcompare.GroupCompareMainClass.main(GroupCompareMainClass.java:13)

@atirtahir3,

I am using GroupDocs.Comparison for Java 19.3 JAR file as an external library, but still same issue.

@ashwin1483,

It seems that you are evaluating the API in trial mode. Because the output has a evaluation mark and API has limitation in such a case.
But the good thing is you can request a temporary license that is actually a time-restricted full license here.
You have to follow the wizard and on step 5 you can request a temporary license. This document will further help you out - Wizard.zip (152.9 KB).
Secondly, make sure, the font-family that your source and target documents have is installed in your environment.

The “Exception in thread 'main” error in Java occurs when your code attempts to use a null object reference, i.e., an object that has not been initialized or has been set to null.

To fix this error, you need to identify the null reference and either initialize the object or assign a value to it before using it. Here are some common causes of this error:

  • Attempting to call a method on a null object reference
  • Trying to access or modify a variable that has not been initialized
  • Passing a null value as an argument to a method that does not allow null values

To avoid this error, always ensure that objects are properly initialized before they are used, and check for null values before attempting to use them. You can also use tools like debugging and logging to help identify the cause of the null reference.

@stevejonn

Using latest version of the API also resolves the issue.