Free Support Forum - aspose.com

Document.getPageCount throws java.lang.NullPointerException

Hi,

When we call Document.getPageCount() just after loading certain documents we’re getting a java.lang.NullPointerException. I will attach an example document here.

nullpointerexample.docx (13.7 KB)

Environment
We’re using v21.4 and I can reproduce this on Mac and on Linux.

JVM
openjdk 11.0.11 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

Stack trace:

Caused by: com.elsevier.dp.works.transformation.exception.WorksTransformationException: Error occurred determining page count
    at com.elsevier.dp.works.transformation.aspose.extractor.PageExtractor.extract (PageExtractor.java:32)
    at com.elsevier.dp.works.transformation.aspose.AsposeWorksTransformer.transform (AsposeWorksTransformer.java:97)
    at com.elsevier.dp.works.transformation.aspose.AsposeWorksTransformer.transform (AsposeWorksTransformer.java:56)
    at com.elsevier.dp.works.transformation.Main.main (Main.java:32)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:829)
Caused by: java.lang.NullPointerException
    at com.aspose.words.zzZX.zzh5 (Unknown Source)
    at com.aspose.words.zzZDK.zzW (Unknown Source)
    at com.aspose.words.zzZDK.zzUb (Unknown Source)
    at com.aspose.words.zzZDD.zzZ (Unknown Source)
    at com.aspose.words.zzZDD.zzN (Unknown Source)
    at com.aspose.words.zzZDO.zzF (Unknown Source)
    at com.aspose.words.zzZDM.zzz (Unknown Source)
    at com.aspose.words.zzZDM.zzW (Unknown Source)
    at com.aspose.words.zzZDM.zzX (Unknown Source)
    at com.aspose.words.zzVG.zzZ (Unknown Source)
    at com.aspose.words.zzVG.zzZ (Unknown Source)
    at com.aspose.words.zzYOL.zzYpI (Unknown Source)
    at com.aspose.words.zzYOL.zzY (Unknown Source)
    at com.aspose.words.zzYOL.zzZ (Unknown Source)
    at com.aspose.words.zzWY.zz8c (Unknown Source)
    at com.aspose.words.zzWY.zzW (Unknown Source)
    at com.aspose.words.zzWY.zzX (Unknown Source)
    at com.aspose.words.zzYYB.zzB (Unknown Source)
    at com.aspose.words.zzYYB.zzC (Unknown Source)
    at com.aspose.words.zzYYB.zzYFC (Unknown Source)
    at com.aspose.words.zzYYB.zzL (Unknown Source)
    at com.aspose.words.zzYXH.zzJ (Unknown Source)
    at com.aspose.words.zzYMM.zza (Unknown Source)
    at com.aspose.words.zz3P.zzJ (Unknown Source)
    at com.aspose.words.zz3Q.zzZxv (Unknown Source)
    at com.aspose.words.zzYYF.zzYFY (Unknown Source)
    at com.aspose.words.Document.updatePageLayout (Unknown Source)
    at com.aspose.words.Document.zzWa (Unknown Source)
    at com.aspose.words.Document.getPageCount (Unknown Source)
    at com.elsevier.dp.works.transformation.aspose.extractor.PageExtractor.extract (PageExtractor.java:30)
    at com.elsevier.dp.works.transformation.aspose.AsposeWorksTransformer.transform (AsposeWorksTransformer.java:97)
    at com.elsevier.dp.works.transformation.aspose.AsposeWorksTransformer.transform (AsposeWorksTransformer.java:56)
    at com.elsevier.dp.works.transformation.Main.main (Main.java:32)
    at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:254)
    at java.lang.Thread.run (Thread.java:829)

@arronhardenels

We have tested the scenario and managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSJAVA-2581. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.

1 Like