2

How can I open a pdf file from my android device(from download folder) on a webview? I tried to open pdf on webview but it supports only web url.Is it possible to open local pdf file on webview. I tried barteksc library, but it is a very large file. Any solutions?

Shanto George
  • 994
  • 13
  • 26
  • Possible duplicate of this https://stackoverflow.com/questions/11613505/how-to-open-local-pdf-file-in-webview-in-android – Ahmad Ayyaz Jun 11 '18 at 07:58
  • barteksc's library is indeed a large library because it contains native libraries for all CPU architectures. Use ABI splits to generate separate APK for different CPU architecture so that the app size will be reduced. – Nabin Bhandari Jun 11 '18 at 08:00
  • webview is not designed to open PDF files, it can only show HTML pages. – Vladyslav Matviienko Jun 11 '18 at 08:05

1 Answers1

2

I would suggest you use the native feature PdfRenderer instead of webview.
From android OS 5.0(lollipop) on-wards you can use this class to show pdf's within the app. If you want to support OS lower than that you can use a library as there is no native support

Read more about the class from the docs here, you can also refer this example provided by google

Aniruddha K.M
  • 7,361
  • 3
  • 43
  • 52