-1

What I want to happen is that when a button is clicked, the user gets sent to another page and then a pdf file is openly displayed (the contents of it) and it is scrollable.

I have absolutely no clue how to go about this, which is why I am posting it in another question because I am aware that there is probably an answer that already explains how to do this, but I am so new to it I do not have any clue how to start!

The software is for an app (android studio), so I cannot use javascript to do it ( I do not think)

It is not a duplicate of that because I really have no clue how to solve the problem as I am too 'beginner-like' and also the fact that that article shows how to do it with internet and I cannot do it with internet for my application

Desthstro
  • 59
  • 7

3 Answers3

0

There are already detailed answers on Stackoverflow: For instance:

How to open/display documents(.pdf, .doc) without external app?

In order to go to a new Page you use :

startActvity(new Intent(context, ActivityName.class));

The new Activity holds an WebView

<WebView
 xmlns:android="http://schemas.android.com/apk/res/android"
 android:id="@+id/webView1"
 android:layout_width="match_parent"
 android:layout_height="match_parent" />

Then you can use

 WebView  wv = (WebView)findViewById(R.id.webView); 
  wv.getSettings().setJavaScriptEnabled(true);
  wv.getSettings().setPluginsEnabled(true);
  wv.getSettings().setAllowFileAccess(true);
  wv.loadUrl(doc);
Community
  • 1
  • 1
phe
  • 26
  • 6
0

Check this, Hope it will help -

1) Render a PDF file using Java on Android

2) https://github.com/jblough/Android-Pdf-Viewer-Library

Community
  • 1
  • 1
Onkar Nene
  • 1,359
  • 1
  • 17
  • 23
  • Thanks for all the quick answers! I am still somewhat confused. I understand that to open a new page I just create an new activity, then on the onclicklistener of a button it will start a new activity. What I do not understand yet is how to display the pdf without internet connectivity (which I forgot to mention!) as all the answers there use internet connectivity. – Desthstro Jul 11 '16 at 09:39
  • You are just opening existing PDF in device storage, Right? Because if you don't want internet connection then you can't download PDF files. – Onkar Nene Jul 11 '16 at 10:14
  • Well what I want is to display a pdf like thing image by image (shown below I think by Dehan) which can be scrolled and viewed, to the extent that it does not require internet connectivity – Desthstro Jul 11 '16 at 11:23
0

I have done similar case in past. What I did is, I load a image by image from the pdf to android ImageView by passing the page number. I did this using Debenu PDF Library For Android

When User click your first Button Open separate activity and get the first page as a Image by passing page number to the pdf library inside the OnCreate method of Activity

If you need more help, feel free to ask..

Dehan Wjiesekara
  • 3,152
  • 3
  • 32
  • 46
  • If you could care to explain exactly how to do this that would be incredible considering you have done this before. To me, having only started using java about 2 weeks ago, this is a mammoth task so I cited this sitexD If it is too difficult to explain in an comment can yo uopen a chat or something? Thanks for all the help so far – Desthstro Jul 11 '16 at 09:42
  • meanwhile you tryout the code, I'll make simple app and put it in github within few hours. it will take few hours since i'm at the office now. :D – Dehan Wjiesekara Jul 11 '16 at 09:46
  • Thank you so much! (nearly there finally!xD) – Desthstro Jul 11 '16 at 09:51
  • @Desthstro Bro here is a complete tutorial and I think you can tryout it. http://www.debenu.com/kb/setup-android-studio-and-debenu-quick-pdf-library/ – Dehan Wjiesekara Jul 11 '16 at 10:12
  • gosh that seems ridiculously complex! I will try and work through it..but no doubt I will come across numerous problems lol as what I need to do is seemingly so difficult! – Desthstro Jul 11 '16 at 10:15
  • I am guessing that I need ot download all the images into a res file then have the onclick send it to a new activity. I think I know how to do this..but after that to make a scrollable pdf file without wifi completely baffles me! – Desthstro Jul 11 '16 at 10:30
  • what you mean by "download all images into a res file" – Dehan Wjiesekara Jul 12 '16 at 04:20