6

I want to open PDF file from locally and then I show the PDF content then if user copy any text then I want to get the copied text. so please suggest me any API or solution related to this problem and the challenging task is to copy text and get it that I want. I have use this code also but its open PDF by using internal app like adobe reader so I don't know that adobe reader give me permission to access copy text.

File file = new File(Environment.getExternalStorageDirectory() + "/test.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(file),"application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
startActivity(intent);
rekire
  • 45,039
  • 29
  • 149
  • 249
Ashutosh Bansal
  • 377
  • 1
  • 5
  • 17
  • Please regard that if you try to open a protected PDF-File the user won't be able to copy any text of it. – Bruno Bieri Sep 20 '12 at 06:43
  • actually pdf file is not protected and my point is this i want to show pdf and when user copy the text then i m able to get that selected text and i dont know how to do this.. – Ashutosh Bansal Sep 20 '12 at 06:52

1 Answers1

5

PDFBox would be your best option considering how easy it is to use. You can have a look at the examples and get going immediately..

EDIT : As @Adinia pointed it out, PDFBox is not working on Android. The reason being PDFBox uses AWT and Swing even for the non-ui related tasks and Android does not support these.

You could have a go at PDFjet and here are some examples to get you started.

EDIT 2: PDFBox-Android (as the name suggests) is now available for Android, as @Theo was so kind to inform.

Swayam
  • 15,855
  • 13
  • 58
  • 102