Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to show pdf file and edit content in android

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);
like image 441
Ashutosh Bansal Avatar asked Sep 20 '12 06:09

Ashutosh Bansal


1 Answers

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.

like image 174
Swayam Avatar answered Nov 11 '22 20:11

Swayam