Hi
I was trying to extract the content of a pdf file and display its content in android. I tired the code in java and it worked.But when i am coding it in android, its not displaying anything.I placed the file in assets folder and then used asset manager(not sure its correct) to get the file.But the output is not shown.Also when i debugged the pgm,its showing some error. The code is given below:

AssetManager assetManager =getAssets();

InputStream stream = null;

try {

    stream = (InputStream) assetManager.open("FirstPdf.pdf");

} catch (IOException e) {

    // handle

}

  PdfReader reader = new PdfReader(stream);


   str=PdfTextExtractor.getTextFromPage(reader, 2);

Error show in debug window:
DalvikVM[localhost:8675]
Thread [<1> main] (Suspended (exception RuntimeException))
ActivityThread.performLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2663
ActivityThread.handleLaunchActivity(ActivityThread$ActivityRecord, Intent) line: 2679
ActivityThread.access$2300(ActivityThread, ActivityThread$ActivityRecord, Intent) line: 125 ActivityThread$H.handleMessage(Message) line: 2033
ActivityThread$H(Handler).dispatchMessage(Message) line: 99 Looper.loop() line: 123 ActivityThread.main(String[]) line: 4627
Method.invokeNative(Object, Object[], Class, Class[], Class, int, boolean) line: not available [native method]
Method.invoke(Object, Object...) line: 521
ZygoteInit$MethodAndArgsCaller.run() line: 868
ZygoteInit.main(String[]) line: 626 NativeStart.main(String[]) line: not available [native method]
Thread [<6> Binder Thread #2] (Running) Thread [<5> Binder Thread #1] (Running)

I would be very grateful if the problem is solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.