简体   繁体   English

Android-WebView显示pdf的加密内容

[英]Android - WebView shows encrypted content of pdf

I am developing an android application in which I tried to load pdf into Webview from the URL mentioned below, 我正在开发一个android应用程序,其中尝试从下面提到的URL将pdf加载到Webview中,

http://ipAddress/SD_BIO/showDocument.jsp?fileName=HIPAA%20Authorization%20Form.pdf&attachmentType=STUDY_INFORMED_CONSENT_FORMS&attachmentTypeId=120&documentId=412

I tried in the following ways , 我尝试了以下方法,

((WebView) findViewById(R.id.pdf)).getSettings().setJavaScriptEnabled(
                true);

        ((WebView) findViewById(R.id.pdf)).getSettings().setAllowFileAccess(
                true);
        ((WebView) findViewById(R.id.pdf)).getSettings().setPluginState(
                PluginState.ON);
        ((WebView) findViewById(R.id.pdf))
                .loadUrl("http://ipAddress/SD_BIO/showDocument.jsp?fileName=HIPAA%20Authorization%20Form.pdf&attachmentType=STUDY_INFORMED_CONSENT_FORMS&attachmentTypeId=120&documentId=412");

The Webview is loaded , but encrypted like below, 已加载Webview,但如下加密, 在此处输入图片说明

Then I modified the loadURL like below, 然后我修改了loadURL如下所示,

((WebView) findViewById(R.id.pdf))
                .loadUrl("http://docs.google.com/gview?embedded=true&url=http://ipAddress1/SD_BIO/showDocument.jsp?fileName=HIPAA%20Authorization%20Form.pdf&attachmentType=STUDY_INFORMED_CONSENT_FORMS&attachmentTypeId=120&documentId=412");

But,it shows "No Preview Available" . 但是,它显示“无预览可用” Also,I could able to see some thirdparty libraries.But,client does not want any third party libraries . 另外,我可以看到一些第三方库。但是,客户端不需要任何第三方库。

Please help me find the solution . 请帮助我找到解决方案。

WebView does not show PDF files. WebView不显示PDF文件。 If http://ipAddress/SD_BIO/showDocument.jsp is returning a PDF file, WebView has no means of displaying it. 如果http://ipAddress/SD_BIO/showDocument.jsp返回PDF文件,则WebView无法显示它。

But,client does not want any third party libraries . 但是,客户不需要任何第三方库。

Your client does not have very many options: 您的客户没有太多选择:

  • Use third-party PDF rendering code. 使用第三方PDF渲染代码。

  • Use a third-party PDF viewer app. 使用第三方PDF查看器应用程序。

  • Serve up something other than PDF, such as HTML. 提供除PDF之外的其他内容,例如HTML。

  • On Android 5.1+, try PdfRenderer , though that is really designed for print previews. 在Android 5.1+上,请尝试PdfRenderer ,尽管它确实是为打印预览而设计的。

  • Hire developers to write a custom PDF renderer from scratch (hundreds of developer-months' worth of work). 雇用开发人员从头开始编写自定义PDF渲染器(数百个开发人员月的工作量)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM