I am a newbie in android world. I tired to create a android project using eclipse IDE, in which i tried reading a pdf file with the help of itext library. This pgm is not showing any output.Please tell me how to correct the code,so that i can extract the text from pdf file stored in Assets folder in the project.
The program code is given as :
public class hello extends Activity {
/** Called when the activity is first created. */
public static final String LOG_TAG="Fifth";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
AssetManager assetManager =getAssets();
InputStream istr = null;
PdfReader reader=null;
String str=null;
int n=0;
try {
istr =(InputStream) assetManager.open("FirstPdf");
reader=new PdfReader(istr);
n=reader.getNumberOfPages();
Log.v(LOG_TAG,"n value:" +n);
str=reader.getPageContent(2).toString();
}
catch (Exception e)
{
e.printStackTrace();
}
TextView tv = new TextView(this);
tv.setText(n);
setContentView(tv);
}
}
Regards Thomas