We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text extraction null pointer exception

Hi, we call below API to convert PDF, but there is one pdf hits null pointer exception as blow:

com.aspose.pdf.Document doc = new com.aspose.pdf.Document(new ByteArrayInputStream(FileUtils.readFileToByteArray(new File(filePath + workingFileName))));
doc.save(filePath + workingFileName);

com.aspose.pdf.TextAbsorber ta = new com.aspose.pdf.TextAbsorber();
doc.getPages().accept(ta)

   pdfExtractor.extractText();
                 PdfExtractor pdfExtractor = new PdfExtractor();
                 pdfExtractor.bindPdf(pdfDoc);

Case 1:
java.lang.NullPointerException
at com.aspose.pdf.PageCollection.accept(Unknown Source)

Case 2:
java.lang.NullPointerException
at com.aspose.pdf.internal.p95.z4.m1(Unknown Source)
at com.aspose.pdf.internal.p95.z4.m1(Unknown Source)
at com.aspose.pdf.internal.p95.z4.m1(Unknown Source)
at com.aspose.pdf.internal.p95.z4.m1(Unknown Source)
at com.aspose.pdf.internal.p95.z4.m4(Unknown Source)
at com.aspose.pdf.internal.p95.z4.m2(Unknown Source)
at com.aspose.pdf.internal.p95.z4.m1(Unknown Source)
at com.aspose.pdf.internal.p95.z4.m1(Unknown Source)
at com.aspose.pdf.internal.p92.z18.m1(Unknown Source)
at com.aspose.pdf.internal.p92.z16.m1(Unknown Source)
at com.aspose.pdf.internal.p11.z13.m1(Unknown Source)
at com.aspose.pdf.ADocument.saveInternal(Unknown Source)
at com.aspose.pdf.Document.saveInternal(Unknown Source)
at com.aspose.pdf.ADocument.save(Unknown Source)
at com.aspose.pdf.Document.save(Unknown Source)

Case 3
java.lang.NullPointerException
at com.aspose.pdf.internal.p15.z29.m9(Unknown Source)
at com.aspose.pdf.internal.p15.z29.m2(Unknown Source)
at com.aspose.pdf.internal.p15.z29.m1(Unknown Source)
at com.aspose.pdf.PageCollection.getUnrestricted(Unknown Source)
at com.aspose.pdf.PageCollection.m1(Unknown Source)
at com.aspose.pdf.PageCollection.get_Item(Unknown Source)
at com.aspose.pdf.facades.PdfExtractor.extractTextInternal(Unknown Source)
at com.aspose.pdf.facades.PdfExtractor.extractText(Unknown Source)
at sg.gov.sla.ers.util.DocumentUtil.isSearchablePDF(DocumentUtil.java:714)
at sg.gov.sla.ers.util.DocumentUtil.convert2Pdf(DocumentUtil.java:508)
at sg.gov.sla.ers.record.myrecord.extensions.bean.MyRecordExtensionPageBean.processPDFConversion(MyRecordExtensionPageBean.java:4749)
at sg.gov.sla.ers.record.myrecord.extensions.bean.MyRecordExtensionPageBean.processSaveRecord(MyRecordExtensionPageBean.java:1290)
at sg.gov.sla.ers.record.myrecord.extensions.concurrent.CreateRecordRunnable.run(CreateRecordRunnable.java:43)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

@jasonjun.ncs.sg

I have observed your comments and like to request you to please share the source PDF file with us. Kindly explain the 3 cases mentioned by you. Every time the exception is thrown, the stack trace is one out of these 3 cases. Is that the scenario? Please clarify, so that we may investigate it further to help you out.