PDF在Google Chrome中直接下载 - 如何在浏览器窗口中显示? [英] PDF downloading directly in Google Chrome -- how to display in browser window instead?

查看:640
本文介绍了PDF在Google Chrome中直接下载 - 如何在浏览器窗口中显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用谷歌浏览器,最近我重新安装了浏览器。



我发现无论我打开的PDF链接是直接下载的。然而,我希望他们能够在浏览器上浏览。



我该如何做到这一点? p

更新后的版本。

解决方案

Chrome需要满足一些要求,对于浏览器本身,另一个用于提供PDF的远程服务器:


  1. 必须为Chrome启用PDF查看器,可以是来自Mozilla的外部 PDF.js ,也可以是内置的Chrome PDF查看器,名为 pdfium (还有其他插件,例如Adobe Acrobat的专有插件或可以使用Foxit,但我不会在这个答案中讨论这些):


    • 在最近的Chrome版本中,'应该自动包含pdfium'查看器。要检查它是否已启用,请在URL栏中键入 about:plugins 。搜索'Chrome PDF Viewer'。它不应被禁用。

    • 要检查'PDF.js',请键入 about:extensions 到URL栏中。搜索'pdf.js'。如果找到它,请启用复选标记。如果您没有找到它,则不会安装它。



    请注意,您只能启用这两个内部PDF查看器中的一个。

  2. 向您的浏览器提供PDF文档的远程服务器需要发送正确的MIME类型和正确的内容处置标题,否则浏览器将不会打开PDF直接地,但只保存它(或提供保存它):


    • HTTP标头需要是:内容-Disposition:Inline not: Content-Disposition:Attachment !) li>
    • MIME类型必须是: application / pdf not: 应用/八位字节流!)。它可能 它也适用于 text / html ,但我没有检查过。


作为附加措施,还请打开 chrome:// flags 'pdf'并查看是否存在可疑设置,这可能会阻止直接在浏览器窗口中呈现PDF。


I have been using Google Chrome and recently I have re-installed my browser.

I found that whatever PDF links I open are directly downloading. However, I want them to be view on browser.

How can I do this?

Chrome is an updated version.

解决方案

For Chrome to open a PDF inline, in the browser window itself, several requirements have to be met, one for the browser itself, the other for the remote server offering the PDF:

  1. There must be a PDF viewer enabled for Chrome, either the external PDF.js one from Mozilla, or the native, builtin Chrome PDF viewer called pdfium (there are other plugins, such as the proprietary ones from Adobe Acrobat or from Foxit which can be used, but I don't discuss these in this answer):

    • In recent Chrome versions, the 'pdfium' viewer should be included automatically. To check if it is enabled, type about:plugins into the URL bar. Search for 'Chrome PDF Viewer'. It should not be disabled.
    • To check for 'PDF.js', type about:extensions into the URL bar. Search for 'pdf.js'. If you find it, enable the checkmark. If you do not find it, it is not installed.

    Note, that you can only enable one of these two internal PDF viewers.

  2. The remote server providing the PDF document to your browser needs to send the correct MIME type and the correct content disposition header, otherwise the browser will not open the PDF directly, but only save it (or offer to save it):

    • the HTTP header needs to be: Content-Disposition: Inline (not: Content-Disposition: Attachment!)
    • the MIME type needs to be: application/pdf (not: application/octet-stream!). It may be the case that it also works for text/html but I haven't checked this.

As an additional measure, please also open chrome://flags, search for 'pdf' and see if there is a suspicious setting which may prevent the direct rendering of PDFs in the browser window.

这篇关于PDF在Google Chrome中直接下载 - 如何在浏览器窗口中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆