question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Accessing a pdf from internal storage throws file not found exception

See original GitHub issue

Am trying a populate a pdf which is stored in internal storage is throwing FileNotFoundException.

    File file1 = new File(Environment.getExternalStorageDirectory()+"/pdf/Read.pdf");
    pdfView.fromFile(file1)
            .defaultPage(1)
            .onPageChange(this)
            .swipeVertical(true)
            .showMinimap(false)
            .load();

But when I manually check the directory, I could see that file exist. Or some times its giving me com.shockwave.pdfium.PdfOpenException: Open document failed in my log

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
shyamsamcommented, Jun 10, 2016

@barteksc thanks for you reply,

am still facing the same issue as @ENOZA has mentioned in earlier comments. I have given the permission in the manifest.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />

Am downloading the file from a remote server to a folder in phone storage. If I go to that particular directory I could see that file exists there and am able to open that file with other pdf viewers. The error an getting is when an populating the pdf. The log is shown below:

com.shockwave.pdfium.PdfOpenException: Open document failed
at com.shockwave.pdfium.PdfiumCore.newDocument(PdfiumCore.java:72)
at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:61)
at    com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:32)
at android.os.AsyncTask$2.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)
0reactions
kondasusmithareddycommented, Dec 4, 2018

Pdf is not working in Kitkat version.When I Click on link,It Displaying Blank Page in My Emulator,Can u help me Please

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to Fix the FileNotFoundException in Java.io - Rollbar
The FileNotFoundException is a checked exception in Java that occurs when an attempt to open a file denoted by a specified pathname fails....
Read more >
java - FileNotFoundException when importing file from storage ...
The file does not exist on Internal Storage. Use below code to solve the issue. public static String getPath(Context context, ...
Read more >
Fix FileNotFoundException in Android 10 Q | by Rommer Cañete
One of which is the scoped storage or scoped access to external ... FileNotFoundException: /storage/myfolder/image.png: open failed: ENOENT.
Read more >
FileNotFoundException - Android Developers
It will also be thrown by these constructors if the file does exist but for some reason is inaccessible, for example when an...
Read more >
How to fix java.io.FileNotFoundException: (Access is denied ...
2. See if some other process is using that file ... This could be another possible reason for "java.io.FileNotFoundException: (Access is denied)". in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found