DImuthuUpe / AndroidPdfViewer

Android view for displaying PDFs rendered with PdfiumAndroid
Apache License 2.0
8.18k stars 1.91k forks source link

PDF Doesn't show on SDK 30 -> Android 10 #975

Open hatimmakki opened 3 years ago

hatimmakki commented 3 years ago

Hi, The pdf stopped showing after I targeted SDK 30. does this library support sdk 30? if yes, what change i need to do?

The pdf doesn't show when run on Android 10

my code:

` Uri path = Uri.fromFile(pdfFile);

        pdfViewer.fromUri(path)
                .password(null)
                .defaultPage(0)
                .enableSwipe(true)
                .swipeHorizontal(false)
                .enableDoubletap(true)
                .spacing(0)
                .enableAnnotationRendering(false)
                .load();

`

thanks

AhmerAfzal1 commented 3 years ago

Maybe this help you.

1stmetro commented 3 years ago

Also having issues with API29/30 with a blank PDF and no errors.....

Anyone found a fix ?

AhmerAfzal1 commented 3 years ago

Try this maybe help you

implementation 'com.github.ahmerafzal1:AhmerPdfium:7.7.2' implementation 'com.github.ahmerafzal1:AhmerPDFViewer:2.8.2'

<com.ahmer.afzal.pdfviewer.PDFView
        android:id="@+id/pdfView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"/>
1stmetro commented 3 years ago

Does your code fix the scoped storage and white pdf's?

I tried to import but causes me issues with duplicate files and manifest issues.

AhmerAfzal1 commented 3 years ago

Yes I fixed

Biplab-Roy commented 3 years ago
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.graphics.drawable.Drawable.draw(android.graphics.Canvas)' on a null object reference
    at com.ahmer.afzal.pdfviewer.PDFView.onDraw(PDFView.java:592)
    at android.view.View.draw(View.java:20234)
    at android.view.View.updateDisplayListIfDirty(View.java:19109)
    at android.view.View.draw(View.java:19962)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4114)
    at androidx.constraintlayout.widget.ConstraintLayout.dispatchDraw(ConstraintLayout.java:1975)
    at android.view.View.updateDisplayListIfDirty(View.java:19100)
    at android.view.View.draw(View.java:19962)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4114)
    at android.view.View.updateDisplayListIfDirty(View.java:19100)
    at android.view.View.draw(View.java:19962)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4114)
    at android.view.View.updateDisplayListIfDirty(View.java:19100)
    at android.view.View.draw(View.java:19962)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4114)
    at android.view.View.updateDisplayListIfDirty(View.java:19100)
    at android.view.View.draw(View.java:19962)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4114)
    at android.view.View.updateDisplayListIfDirty(View.java:19100)
    at android.view.View.draw(View.java:19962)
    at android.view.ViewGroup.drawChild(ViewGroup.java:4337)
    at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4114)
    at android.view.View.draw(View.java:20237)
    at com.android.internal.policy.DecorView.draw(DecorView.java:784)
    at android.view.View.updateDisplayListIfDirty(View.java:19109)
    at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:686)
    at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:692)
    at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:801)
    at android.view.ViewRootImpl.draw(ViewRootImpl.java:3373)
    at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3163)
    at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2532)
    at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1505)
    at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7354)
    at android.view.Choreographer$CallbackRecord.run(Choreographer.java:1092)
    at android.view.Choreographer.doCallbacks(Choreographer.java:888)
    at android.view.Choreographer.doFrame(Choreographer.java:819)
    at android.view.Choreographer$FrameHandler.handleMessage(Choreographer.java:991)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:201)
    at android.app.ActivityThread.main(ActivityThread.java:6810)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)

For SDK 28 I used @AhmerAfzal1 library but any other error I am getting. While for same code @barteksc Library working perfect.

AhmerAfzal1 commented 3 years ago

@Biplab-Roy I was changed some code for according to me. Therefore maybe some errors raises, I make support for SDK 30, fixed crashes, and night mode

1stmetro commented 3 years ago

If i implement scoped storage functions the original PDFView code works correctly,

My question is how do you open the pdf for pdfview without using the ACTION_OPEN_DOCUMENT/ACTION_OPEN_Content in Android Q perhaps someone has solved this small issue.?

islamYMansour commented 2 years ago

@AhmerAfzal1 if face the same problem and I try to use your library but it crashes like Biplab-Roy