0

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

Chetan Joshi
  • 5,582
  • 4
  • 30
  • 43
eshteghel company
  • 471
  • 1
  • 7
  • 22

1 Answers1

0

Use can use Android PDFView Library -below link has complete implementation of Library

AndroidPdfViewer

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

Android Resumable Download

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:

Boken
  • 4,825
  • 10
  • 32
  • 42
Chetan Joshi
  • 5,582
  • 4
  • 30
  • 43