Use the below code to get all the content of pdf file as a text. Before executing the code change the pdfFullPath.
String pdfFullPath="c://pdffile/myfile.pdf";
File file = new File(pdfFullPath);
try{
//PDDocument doc = PDDocument.load((File) file);
// file = new File(filePath);
PDFParser parser = new PDFParser(new RandomAccessFile(file,"r")); // update for PDFBox V 2.0
parser.parse();
COSDocument cosDoc = parser.getDocument();
PDFTextStripper pdfStripper = new PDFTextStripper();
PDDocument pdDoc = new PDDocument(cosDoc);
pdDoc.getNumberOfPages();
pdfStripper.setStartPage(1);
pdfStripper.setEndPage(10);
// reading text from page 1 to 10
// if you want to get text from full pdf file use this code
// pdfStripper.setEndPage(pdDoc.getNumberOfPages());
String Text = pdfStripper.getText(pdDoc);
System.out.println(Text);
}catch(Exception e)
{
System.out.println(e.toString());
}