how to get pdf from internal storage in android Using WebView or AnyConcept. i have to get pdf in an activity from internal storage.Can anyone of u guys let me know about this .Thank You.
Asked
Active
Viewed 1,825 times
1
-
there is no no native way of displaying a "local" pdf from within an andrioid activity. – Hector Mar 22 '17 at 05:31
-
2There are number of ways by which you can view PDF. 1)Using Web View 2)Using android PdfRenderer class (https://developer.android.com/reference/android/graphics/pdf/PdfRenderer.html) 3)You can use JavaScript(https://github.com/loosemoose/androidpdf) 4)You can use android Open source library for PDF reader. – ViramP Mar 22 '17 at 05:37
-
Thnak you Viram Will Check and let u know – Programing World Mar 22 '17 at 05:54
-
hi viram,what u gave the second link is copy data from asstes and display using webview. – Programing World Mar 22 '17 at 06:21
1 Answers
0
String filename = null;
File file = new File(Environment.getExternalStorageDirectory().getAbsolutePath() +"/"+ filename);
Intent target = new Intent(Intent.ACTION_VIEW);
target.setDataAndType(Uri.fromFile(file),"application/pdf");
target.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
Intent intent = Intent.createChooser(target, "Open File");
startActivity(intent);
and give pdf filename

Programing World
- 89
- 12

Karthik
- 102
- 13
-
-
Thnaks For giving Quick Response karthik.I tried this for PDF it is not working . – Programing World Mar 22 '17 at 05:47
-
File pdfFile = new File(Environment.getExternalStorageDirectory() + "/mavenpdf/" + "3074-MANUAL.pdf"); // -> filename = maven.pdf Uri path = Uri.fromFile(pdfFile); Intent pdfIntent = new Intent(Intent.ACTION_VIEW); pdfIntent.setDataAndType(path, "application/pdf"); pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); – Karthik Mar 22 '17 at 05:59
-
I tried dude but i didn't get solution for that. a empty screen is appeared. – Programing World Mar 22 '17 at 06:18
-
-
Environment.getExternalStorageDirectory().toString()+ "/PDF/" + "INVOICE.pdf" This is my file name. – Programing World Mar 22 '17 at 06:23
-
Karthik,Can u provide the source code for both xml and java please may be that could helpful to me. – Programing World Mar 22 '17 at 06:42
-
Karthik I got PDF in activity.But with that pdf i would like to place a button at end of the screen .can i know how could i do this. – Programing World Mar 22 '17 at 06:54
-