Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to extract text from a pdf file in android emulator

 
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have tried the following code to extract text from pdf file on android.



it works when the file is in the file-system,but i want it to work ,when the file is in the sdcard
something similar to this:

 
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For starters, PDF files are binary, not text. That means you can't use Readers to work with them, you need to use Streams.

So the actual problem is how to get an InputStream from a file on the SD card? The Android Dev Guide has a page called "Data Storage" that talks about using SD cards.
 
Mohit G Gupta
Ranch Hand
Posts: 634
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FileReader doesnot works for pdf files.
please,tell me how to use pdfbox within the android
 
Ulf Dittmer
Rancher
Posts: 43016
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

FileReader doesnot works for pdf files.


Not just FileReader - all Readers and Writers. It's crucial that you understand the difference between text files and binary files.

please,tell me how to use pdfbox within the android


I have no idea whether PDFBox works on Android, but I pointed you to a resource that explains how to get an InputStream from a file on an SD card, and it seems that PDDocument.load can use an InputStream as well as a Reader. What else are you looking for?
 
Note to self: don't get into a fist fight with a cactus. Command this tiny ad to do it:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic