I am trying to fetch some data from a PDF file in Java using apache PDFBox(1.8.9). I have added the jar in my buildpath and classpath (in Eclipse-Mars)
I am getting a null pointer exception while creating a PDFTextStripper
object.
import java.io.File;
import org.apache.pdfbox.util.PDFTextStripper;
import org.apache.pdfbox.pdmodel.PDDocument;
public class MainClass {
public static void main(String[] args) {
PDDocument pd ;
try{
StringBuilder sb = new StringBuilder();
File input = new File("C:\\Result.pdf");
pd = PDDocument.load(input);
PDFTextStripper s = new PDFTextStripper();
}
catch(Exception e)
{
e.printStackTrace();
}
}
}
The error I am getting is :
java.lang.NullPointerException
at org.apache.pdfbox.util.TextNormalize.findICU4J(TextNormalize.java:54)
at org.apache.pdfbox.util.TextNormalize.<init>(TextNormalize.java:45)
at org.apache.pdfbox.util.PDFTextStripper.<init>(PDFTextStripper.java:229)
at MainClass.main(MainClass.java:17)
(Line 17 is where I am trying to create a PDFTextStripper object)