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.

Can not download pdf from remote URI

See original GitHub issue

My snippet:


pdfView = findViewById(R.id.pdfView);
        pdfView.fromUri(Uri.parse("http://dl.dropboxusercontent.com/s/2v42h36tdcd6ii8/portrait.pdf"))
                .defaultPage(currentPage)
                .swipeHorizontal(true).load();

But I get error:

 E/PDFView ( 8973): load pdf error
 E/PDFView ( 8973): java.io.FileNotFoundException: No content provider: http://dl.dropboxusercontent.com/s/2v42h36tdcd6ii8/portrait.pdf
 E/PDFView ( 8973):	at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:758)
 E/PDFView ( 8973):	at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:662)
 E/PDFView ( 8973):	at android.content.ContentResolver.openFileDescriptor(ContentResolver.java:575)
 E/PDFView ( 8973):	at com.github.barteksc.pdfviewer.source.UriSource.createDocument(UriSource.java:37)
 E/PDFView ( 8973):	at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:53)
 E/PDFView ( 8973):	at com.github.barteksc.pdfviewer.DecodingAsyncTask.doInBackground(DecodingAsyncTask.java:25)
 E/PDFView ( 8973):	at android.os.AsyncTask$2.call(AsyncTask.java:287)
 E/PDFView ( 8973):	at java.util.concurrent.FutureTask.run(FutureTask.java:234)
 E/PDFView ( 8973):	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
 E/PDFView ( 8973):	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
 E/PDFView ( 8973):	at java.lang.Thread.run(Thread.java:841)

Is method pdfView.fromUri not work with remote url?

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
rahulkushwaha482commented, Aug 18, 2021

use like this:-

package com.pdfpreviewapp;

import android.os.AsyncTask;
import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;
import androidx.appcompat.app.AppCompatActivity;
import com.github.barteksc.pdfviewer.PDFView;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;

public class SecondActivity extends AppCompatActivity {
    PDFView pdfView;
    ProgressBar progressCircular;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_second);
        pdfView = findViewById(R.id.pdfView);
        progressCircular = findViewById(R.id.progress_circular);
        progressCircular.setIndeterminate(true);
        new RetrivePDFStream().execute();
    }

    class RetrivePDFStream extends AsyncTask<Void, Void, Void> {

        protected Void doInBackground(Void... voids) {
            try {
                InputStream input = new URL("http://www.africau.edu/images/default/sample.pdf").openStream();
                pdfView.fromStream(input).load();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }

        @Override
        protected void onPreExecute() {
            super.onPreExecute();
            progressCircular.setVisibility(View.VISIBLE);
        }

        @Override
        protected void onPostExecute(Void unused) {
            super.onPostExecute(unused);
            progressCircular.setVisibility(View.GONE);
        }
    }
}
1reaction
alexei-28commented, Oct 16, 2017

So I need to download pdf from remote URI by another tool, e.g. Retrofit and view locally by PDFViewer?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Download pdf document from remote url - php - Stack Overflow
I am trying to get through an API, a live pdf file, and then download that file to my users. To demonstrate the...
Read more >
How to return a file that open in browser embed not download?
You can use FileStreamResult to show pdf file, it will not start download. ... You can change your code like below, and create...
Read more >
How to download a PDF via WKWebVie… - Apple Developer
I managed to download the documents to local storage (temp folder) and to open it in QuickLookPreviewController with a little trick: The response...
Read more >
Instantiate a Download from a Remote URL - PSPDFKit
If you want to annotate a remote document or make changes to it, you can use URLSession to download the PDF. Then move...
Read more >
FileSystem - Expo Documentation
The remote URI to download from. fileUri, string. The local URI of the file to download to. If there is no file at...
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