I have searched already and not found any solution for show pdf file in application
The point is i have to show pdf from asset or raw folder not from web
I have already tried in webview with code
WebView webview = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.setContentDescription("application/pdf");
webview.loadUrl("file:///android_asset/button11.pdf");
but its not woking.
i need help on that thanks in advance
This is the code I use to read a pdf from the filesystem, I hope it helps!
File file = new File("/path/to/file");
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
try {
context.startActivity(intent);
}
catch (ActivityNotFoundException e) {
Toast.makeText(context, "No application available to view PDF", Toast.LENGTH_LONG).show();
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With