0

I know this question seems simple and already asked but I search and it isn't. I want to open pdf in my webview so I search I found 2 main solutions :

1) Google docs : But it does not read from SDCard

2) Pdf.js that seems better and works on pdf in SDCard

To use it want to do something like that :

 <iframe src="file:///android_asset/pdfjs/web/viewer.html?file=" + file.getAbsolutePath() + file + "&embedded=true' 
          width='100%' height='100%' 
          style='border: none;'></iframe>"

But I can't test it ! I relatively new to android and I don't understand how to implement pdf.js in my app on android studio...

Can someone tell me step by step how to install .js file in android studio ?

EDIT

Sorry I misunderstood things, I thought pdf.js was some kind of lib that must be installed.

But I still have my problem, how can I display a pdf in a div with pdf.js ?

Kolopox
  • 276
  • 1
  • 4
  • 17
  • did you try searching? all these topics have been discussed like a million times on stackoverflow already. For instance, check [this](https://stackoverflow.com/questions/14171316/load-html-files-from-raw-folder-in-web-view) or [this](https://stackoverflow.com/questions/7805127/how-to-load-html-file-stored-inside-sd-card-in-the-web-view) You can also find a good example of usage [here](https://bitbucket.org/butelo/pdfviewer/src) – x0r Jun 15 '17 at 08:58
  • @x0r I searched and your comment didn't really answer me, I know how to put .html in webview from SDCard but what I want to know is how to implements pdf.js. The example you gave is great but the folder is in assets and on android studio I don't have this folder :/ – Kolopox Jun 15 '17 at 09:31
  • what's the problem to create assets folder in AS if you don't have one? – x0r Jun 15 '17 at 09:35
  • @x0r Yeah my bad I missunderstood assets with a directory like libs... If I put pdf.js in my SDCard (where my index.html is) it should work right ? But maybe you can explain me one last thing, where in his index.html (in the exemple you gave) is he printing the pdf ? I know a bit of html and I don't see where it is – Kolopox Jun 15 '17 at 09:47
  • Q. "how can I display a pdf in a div with pdf.js?" A. put iframe inside div – async5 Jun 15 '17 at 12:11
  • @async5 the same way I did in my exemple ? – Kolopox Jun 15 '17 at 12:35
  • maybe, what are those other args after `..?file=" + file.getAbsolutePath()` – async5 Jun 15 '17 at 12:45
  • @async5 Don't really know, I found this exemple on an answer from someone that used google docs. The problem with this example is that he use "viewer.html?file=" and I don't want (I don't even know if it's possible) to put an html page inside my own html page, can't I just "src="myPDFfile" ? – Kolopox Jun 15 '17 at 13:01

0 Answers0