How to render a PDF file in Android

后端 未结 9 959
猫巷女王i
猫巷女王i 2020-11-22 02:09

Android does not have PDF support in its libraries. Is there any way to render PDF files in the Android applications?

9条回答
  •  臣服心动
    2020-11-22 02:30

    Taken from my blog:

    public class MyPdfViewActivity extends Activity {
    
      @Override
      protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        WebView mWebView=new WebView(MyPdfViewActivity.this);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.getSettings().setPluginsEnabled(true);
        mWebView.loadUrl("https://docs.google.com/gview?embedded=true&url="+LinkTo);
        setContentView(mWebView);
      }
    }
    

提交回复
热议问题