使用库 github.barteksc.pdfviewer 在我的应用程序中加载 PDF 时出现错误

I am getting an error while loading a PDF in my app with the library github.barteksc.pdfviewer

这是我在 logcat

中遇到的错误
E/PDFView: load pdf error
     java.io.IOException: cannot create document: File not in PDF format or corrupted.
         at com.shockwave.pdfium.PdfiumCore.nativeOpenMemDocument(Native Method)
         at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:126)
         at com.github.barteksc.pdfviewer.source.InputStreamSource.createDocument(InputStreamSource.java:37)
         at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:53)
         at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:25)
         at android.os.AsyncTask.call(AsyncTask.java:288)
         at java.util.concurrent.FutureTask.run(FutureTask.java:237)
         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
         at java.lang.Thread.run(Thread.java:841)

barteksc/AndroidPdfViewer issue 175

中有报道

Had the same error. For some reason reading PDF directly from assets did not work, and gave the above mentioned error.

So copied it from asset to cache dir, and then all worked.

但首先,请仔细检查您是否可以打开该 PDF 文件(独立于您的执行环境,在您的 Java 程序之外)。