How to load a pdf on android from a url?

前端 未结 2 1423
深忆病人
深忆病人 2021-01-06 08:11

I have a page that contains a listView and each item is supposed to open a pdf file from a url, but I don\'t know how to load a pdf file from a url or even how to load a pdf

相关标签:
2条回答
  • 2021-01-06 08:38
    WebView webview1 = (WebView) findViewById(R.id.webview1);
    webview.getSettings().setJavaScriptEnabled(true); 
    String filename = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters.pdf";
    String filename1 = "http://www.adobe.com/devnet/acrobat/pdfs/pdf_open_parameters1.pdf";
    

    possible duplicate : Android : How to Load PDF?

    pass separate seperate URl on

      ListView lt = (ListView) findViewById(R.id.listview);
    
                lt.setOnItemClickListener(new OnItemClickListener() {
    
                    @Override
                    public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
                            long arg3) {
                        // TODO Auto-generated method stub
    
                        if (arg2 == 1) {
                              webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + filename);
                        }
    
                        if (arg2 == 2) {
        webview.loadUrl("http://docs.google.com/gview?embedded=true&url=" + filename1);
                        }
    
                    }
                });
    
    0 讨论(0)
  • 2021-01-06 08:42

    You can try browser to open pdf file in that like below code:

    http://docs.google.com/gview?embedded=true&url=yoururl
    

    where yoururl will be your pdf url link.

    0 讨论(0)
提交回复
热议问题