johngray1965 / PdfiumAndroidKt

Pdfium Android binding with Bitmap rendering ( >= API 21 )
Other
31 stars 12 forks source link

Error when clicking the link in the pdf file #20

Closed dorukkangal closed 3 weeks ago

dorukkangal commented 8 months ago

Hello, some users encounter the following error when opening the pdf files Used library version: 1.0.14

Function used to open pdf file:

suspend fun renderFile(pdf: File): List<PdfPage> {
    val parcelFileDescriptor = ParcelFileDescriptor.open(pdf, ParcelFileDescriptor.MODE_READ_ONLY)
    val pdfDocument = pdfiumCore.newDocument(parcelFileDescriptor)

    return renderPdf(pdfDocument).also {
        pdfPages.addAll(it)
    }
}

Error detail:

java.lang.UnsatisfiedLinkError: No implementation found for long io.legere.pdfiumandroid.PdfiumCore.nativeOpenDocument(int, java.lang.String) (tried Java_io_legere_pdfiumandroid_PdfiumCore_nativeOpenDocument and Java_io_legere_pdfiumandroid_PdfiumCore_nativeOpenDocument__ILjava_lang_String_2) - is the library loaded, e.g. System.loadLibrary?
    at io.legere.pdfiumandroid.PdfiumCore.nativeOpenDocument(SourceFile)
    at io.legere.pdfiumandroid.PdfiumCore.newDocument(SourceFile:57)
    at io.legere.pdfiumandroid.PdfiumCore.newDocument(SourceFile:45)
    at io.legere.pdfiumandroid.suspend.PdfiumCoreKt$newDocument$2.invokeSuspend(SourceFile:26)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(SourceFile:33)
    at kotlinx.coroutines.DispatchedTask.run(SourceFile:108)
    at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(SourceFile:793)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(SourceFile:697)
    at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(SourceFile:684)
johngray1965 commented 8 months ago

1.0.14 is rather old. Do you see on the latest? That looks like a race condition on loading the native libraries, but I reworked it recently so everything will wait until the native libraries are loaded.

johngray1965 commented 3 weeks ago

Reopen if you continue to see this.