afreakyelf / Pdf-Viewer

A Lightweight PDF Viewer Android library which only occupies around 80kb while most of the Pdf viewer occupies up to 16MB space.
https://afreakyelf.github.io/Pdf-Viewer/
MIT License
822 stars 173 forks source link

application crashing on opening pdf with url #113

Closed realjoni17 closed 8 months ago

realjoni17 commented 8 months ago

on opening the big file with url when we press back stack it suddenly crashes

github-actions[bot] commented 8 months ago

Thank you for creating your first issue. We appreciate your help in making this project better. We will look into it, and get back to you soon. Need help or want to discuss this issue? Join our Discord community here to ask questions and discuss this issue live!

afreakyelf commented 8 months ago

Hey can you paste the logcat?

houkhan commented 8 months ago

Hello, I have also encountered related problems. When opening a relatively large pdf, when the PDF is still loading, that is, the loading animation has not disappeared, closing the page at this time will have this problem when rewriting and opening. When following the crash log.

************* Crash Head ****************
Time Of Crash      : 2024_03_26-10_14_45
Rom Info           : RomInfo{name=xiaomi, version=V12.5.1.0.QEECNXM}
Device Manufacturer: Xiaomi
Device Model       : MIX 3
Android Version    : 10
Android SDK        : 29
App VersionName    : 1.1
App VersionCode    : 2
************* Crash Head ****************

java.io.IOException: file not in PDF format or corrupted
    at android.graphics.pdf.PdfRenderer.nativeCreate(Native Method)
    at android.graphics.pdf.PdfRenderer.<init>(PdfRenderer.java:169)
    at com.rajat.pdfviewer.PdfRendererCore.openPdfFile(PdfRendererCore.kt:142)
    at com.rajat.pdfviewer.PdfRendererCore.<init>(PdfRendererCore.kt:76)
    at com.rajat.pdfviewer.PdfRendererView.init(PdfRendererView.kt:148)
    at com.rajat.pdfviewer.PdfRendererView.init(PdfRendererView.kt:143)
    at com.rajat.pdfviewer.PdfRendererView.initWithFile(PdfRendererView.kt:107)
    at com.rajat.pdfviewer.PdfRendererView$initWithUrl$1.onDownloadSuccess(PdfRendererView.kt:96)
    at com.rajat.pdfviewer.PdfDownloader.checkAndDownload(PdfDownloader.kt:54)
    at com.rajat.pdfviewer.PdfDownloader.access$checkAndDownload(PdfDownloader.kt:13)
    at com.rajat.pdfviewer.PdfDownloader$1.invokeSuspend(PdfDownloader.kt:31)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:367)
    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable(Cancellable.kt:30)
    at kotlinx.coroutines.intrinsics.CancellableKt.startCoroutineCancellable$default(Cancellable.kt:25)
    at kotlinx.coroutines.CoroutineStart.invoke(CoroutineStart.kt:110)
    at kotlinx.coroutines.AbstractCoroutine.start(AbstractCoroutine.kt:126)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch(Builders.common.kt:56)
    at kotlinx.coroutines.BuildersKt.launch(Unknown Source:1)
    at kotlinx.coroutines.BuildersKt__Builders_commonKt.launch$default(Builders.common.kt:47)
    at kotlinx.coroutines.BuildersKt.launch$default(Unknown Source:1)
    at com.rajat.pdfviewer.PdfDownloader.<init>(PdfDownloader.kt:31)
    at com.rajat.pdfviewer.PdfRendererView.initWithUrl(PdfRendererView.kt:84)
    at com.rajat.pdfviewer.PdfViewerActivity.initPdfViewer(PdfViewerActivity.kt:360)
    at com.rajat.pdfviewer.PdfViewerActivity.loadFileFromNetwork(PdfViewerActivity.kt:351)
    at com.rajat.pdfviewer.PdfViewerActivity.init(PdfViewerActivity.kt:254)
    at com.rajat.pdfviewer.PdfViewerActivity.onCreate(PdfViewerActivity.kt:243)
    at android.app.Activity.performCreate(Activity.java:7893)
    at android.app.Activity.performCreate(Activity.java:7880)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1307)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3283)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3457)
    at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:83)
    at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:135)
    at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2044)
    at android.os.Handler.dispatchMessage(Handler.java:107)
    at android.os.Looper.loop(Looper.java:224)
    at android.app.ActivityThread.main(ActivityThread.java:7562)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:539)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:950)
harshad008 commented 8 months ago

Any solution for this issue?

houkhan commented 8 months ago

@harshad008 I found this and another problem to be a bug. I listed the solution under another problem, but it is not very elegant. Reference: https://github.com/afreakyelf/Pdf-Viewer/issues/114

afreakyelf commented 8 months ago

Hi, The Above issue has been fixed in new release. https://github.com/afreakyelf/Pdf-Viewer/releases/tag/v2.1.0

Please migrate to Maven central. More here: https://github.com/afreakyelf/Pdf-Viewer/releases/tag/v2.1.0

Thank you for using the library. Please reopen/raise a new issue if you still face this error.

Join our discord for more updates!