I have this project that I have web view int it which contain PDF
hyper links, when I click on a link, the PDF
is being downloaded and opened by adobe reader after being downloaded.
However; the client requested a new feature which is cancelling download (in case a user wants to cancel the download if the PDF
's size is large)
how can I do it? how can I stop the download command that started after clicking on the link in the PDF

- 5,582
- 4
- 30
- 43

- 471
- 1
- 7
- 22
1 Answers
Use can use Android PDFView Library -below link has complete implementation of Library
Android PDFView is available in Maven Central.
<dependency>
<groupId>com.joanzapata.pdfview</groupId>
<artifactId>android-pdfview</artifactId>
<version>1.0.4</version>
<type>apklib</type>
</dependency>
Or via gradle:
compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
Include PDFView in your layout
<com.joanzapata.pdfview.PDFView
android:id="@+id/pdfview"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
Load a PDF file
pdfView.fromAsset(pdfName)
.pages(0, 2, 1, 3, 3, 3)
.defaultPage(1)
.showMinimap(false)
.enableSwipe(true)
.onDraw(onDrawListener)
.onLoad(onLoadCompleteListener)
.onPageChange(onPageChangeListener)
.load();
pages is optional, it allows you to filter and order the pages of the PDF as you need onDraw is also optional, and allows you to draw something on a provided canvas, above the current page
Resumable Download Resumable download allow users to pause an ongoing download, and begin the download task again whether it is paused or interrupted by unusual situations.
How to achieve resumable download? When we communicate with Hypertext Transfer Protocol(HTTP) server, we can use “Byte serving”, which allows send only a portion of an HTTP/1.1 message form a server to a client. When we already downloaded part of a file, we only need to ask the server for the rest of the file. Using Range request header example:

- 4,825
- 10
- 32
- 42

- 5,582
- 4
- 30
- 43
-
1it says that it needs libraries of size 16MB which is even bigger than my app (14mb) i can't have a final apk of 30 mbs – eshteghel company Feb 22 '17 at 12:23
-
then you need to fire Intent for opening PDF in Adobe reader check if its is available or not in Android ,and if its not there open Adobe reader Application in Play store app . its just like you depend third party app.In general many apps doing this for opening documents. – Chetan Joshi Feb 22 '17 at 12:29
-
you should add your downloader with pause and start and stop buttons . – Chetan Joshi Feb 22 '17 at 12:40
-
how to do so, what's to be called on pause and stop – eshteghel company Feb 22 '17 at 12:42
-
see this link http://stackoverflow.com/questions/25480725/download-file-with-pause-and-resume-button – Chetan Joshi Feb 22 '17 at 12:44
-
is it possible to load pdf url using this library that means view pdf from online – Zahidul Mar 28 '18 at 11:18