I'm trying to load PDF(over 2MB) from a uri with barteksc Android Viewer, but it doesn't work

1.1k views Asked by At

I started this from simple example and here's the code.

I tested several pdf documents from url but I could see only blank spaces on my mobile screeen.

Those pdf documents was opened in the browsers though...

so am I missing something?

please get me some advices...

thanks in advance!!

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    PDFView pdfView = (PDFView) findViewById(R.id.pdfView);
    pdfView.fromUri(Uri.parse("http://xxxxxx/xxx.pdf"))
            .enableSwipe(true)
            .enableDoubletap(true)
            .swipeVertical(false)
            .defaultPage(1)
            .showMinimap(false)
            .enableAnnotationRendering(false)
            .password(null)
            .showPageWithAnimation(true)
            .load();
}
1

There are 1 answers

0
Brumanuel On

The library cant load from Http, you need download file and load from local Uri.

And remember you need android.permission.WRITE_EXTERNAL_STORAGE for download and read file.

As per android official doc :

Android 6.0 Marshmallow introduced a new permissions model that lets apps request permissions from the user at runtime, rather than prior to installation. Apps that support the new model request permissions when the app actually requires the services or data protected by the services.