I am currently testing samples of reading PDF using itext in android but i have a problem. The code below does not display anything in android emulator:
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
AssetManager assetManager = getAssets();
InputStream istr = null;
PdfReader reader=null;
String str= null;
try {
istr =(InputStream) assetManager.open("resume.pdf");
reader=new PdfReader(istr);
str = PdfTextExtractor.getTextFromPage(reader, 1).toString();
//str=reader.getPageContent(1).toString();
}
catch (Exception e)
{
e.printStackTrace();
}
TextView tv = (TextView) findViewById(R.id.txtview);
tv.setText(str);
}
The code is working but it does not display the contents of the PDF.
I think the problem here its not opening the PDF Document properly?
My Goal here is to EXTRACT text from a PDF Document and Transfer it to a Variable in the Code then display it.
I am using iText Version 5.3.3.