I am using AsyncTask class to fetch text from a pdf file using PDFBox. But the problem is that if the size of pdf file is very large then it takes a huge amount of time to load. Is there are any other solutions to fetch text or content from large pdf file.This is my class:
public class AsyncTaskClass extends AsyncTask<Void,Void,Void>{
@Override
protected void onPreExecute(){
super.onPreExecute();
pd.setMessage("Loading...");
pd.show();
}
@Override
protected Void doInBackground(Void... voids) {
String root = Environment.getExternalStorageDirectory().getAbsolutePath();
final File file = new File(root+"/download/half-girlfriend-chetan-bhagat.pdf");
try {
PDDocument document = PDDocument.load(file);
PDFTextStripper stripper = new PDFTextStripper();
text = stripper.getText(document);
}catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
super.onPostExecute(result);
pd.dismiss();
getcontent.setText(text);
}
}