Search code examples
javaandroidpdf-viewer

Display PDF using PDF Viewer from url


I have this code:

 public class ViewBookActivity extends AppCompatActivity {

     PDFView pdfbook;

     @Override
     protected void onCreate(Bundle savedInstanceState) {

         super.onCreate(savedInstanceState);
         setContentView(R.layout.activity_view_book);
         Intent intent = getIntent();

         Uri PDF_URL = Uri.parse(intent.getStringExtra("PDF_URL")) ;
         /*url looks like this http://192.168.8.124/Book/One-1.pdf*/
         Toast.makeText(this, "", Toast.LENGTH_SHORT).show();
         pdfbook = (PDFView) (findViewById(R.id.pdfbook));
         pdfbook.fromUri(PDF_URL).load();
         Log.v("PDFVIEW",PDF_URL.toString());

     }
  }

so I have that code and my URL looks like so http://192.168.8.124/Book/One-1.pdf so when I paste this in my browser I can see the pdf but I cant view it in the device it just shows a blank activity

I am using this API https://github.com/barteksc/AndroidPdfViewerV2


Solution

  • i was able to solve this its a long piece of code but here is the github for it and the youtube tutorial on it please note the youtube tutorial isnt mine just the code is

    https://www.youtube.com/watch?v=rcE4zUiwwbo

    https://github.com/kunz398/android_openPdf