Tuesday, 29 December 2020

How to show a pdf file from storage using AndroidPdfViewer library?

I want to load a pdf file from external storage (Download/Pdfs/myfile.pdf) using AndroidPdfViewer but it shows blank screen without any error. I tried lots of ways but it's not working.

public class PdfViewActivity2 extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        File path = new File(Environment.getExternalStorageDirectory().getPath() + "/Download/Pdfs/myfile.pdf");
        PDFView pdfView = findViewById(R.id.pdfView);
        pdfView.fromFile(path).load();

I have a pdf file in my "Download/Pdfs/myfile.pdf" and i used the above code to load the file but it's not working. I have given storage permission manually from settings. Can anyone please correct me where i am making a mistake.



from How to show a pdf file from storage using AndroidPdfViewer library?

No comments:

Post a Comment