0

I want to load pdf from url and I'm using PDFViewer library for this. But, it is showing blank when opening my app. :( I want your help.

This is my code:

        PDFView pdfView = findViewById(R.id.pdfView);
            pdfView.fromUri(Uri.parse("https://firebasestorage.googleapis.com/v0/b/pdff-69823.appspot.com/o/ehp1.pdf?alt=media&token=9bb1792e-0787-461c-a6a8-1be6724be93f")).load();

And, this is my XML for this:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical">

    <com.github.barteksc.pdfviewer.PDFView
        android:id="@+id/pdfView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
</LinearLayout>

And, I'm using this dependency:

    implementation 'com.github.barteksc:android-pdf-viewer:3.2.0-beta.1'

Dibas Dauliya
  • 639
  • 5
  • 20

1 Answers1

0

Why I cannot open PDF from URL?

Downloading files is long running process which must be aware of Activity lifecycle, must support some configuration, data cleanup and caching, so creating such module will probably end up as new library.

I think this library only support files that are already exist in the device storage or you can use other options like fromBytes(byte[]) or fromStream(InputStream).

Another option is you can download and load the file.

If you opt live rendering then go for another options like Pdfjs etc..

Mable John
  • 4,518
  • 3
  • 22
  • 35