无法在 Chrome 中加载 PDF 文档

编程入门 行业动态 更新时间:2024-10-26 16:22:20
本文介绍了无法在 Chrome 中加载 PDF 文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的服务器上存储了一个 PDF 文件.我无法通过 URL "sitename/pdfName.pdf" 使用 Google Chrome(或 Ubuntu Chromium)访问该文件;而我可以在 Internet Explorer 或 FireFox 中毫无问题地访问相同的 PDF.

I have a PDF file stored on my server. I am unable to access the file using Google Chrome (or Ubuntu Chromium) via URL "sitename/pdfName.pdf"; while I am able to access the same PDF in Internet Explorer or FireFox without a problem.

Chrome 出现此错误:无法加载 PDF 文档"

Chrome is giving this error: "Failed to load PDF document"

在此链接中查找附加错误错误图片.

Find attaching the error in this link Error Image.

推荐答案

当我们遇到这个问题时,能用和不能用的 PDF 文件的唯一区别在于 PDF 文档本身的第一行.这是导致错误的旧 PDF 与在启用二进制的文本编辑器(在本例中为 vim -b)中看到的固定版本之间的区别:

When we encountered this problem, the only difference between PDF files that did and did not work was in the fist line of the PDF document itself. Here's the difference between the old PDF that caused the error and the fixed version as seen in a binary-enabled text-editor (in this case vim -b):

原始 PDF 文件:

%PDF-1.6^M%<e2><e3><cf><d3>^M

固定的PDF文件:

%PDF-1.6^M %<e2><e3><cf><d3>^M

这样就从源头上解决了问题,无需再给受害者安装额外的软件或重新安装chrome的负担.

So the problem was solved at the source, no need to burden the victims with installing extra software or reinstalling chrome.

我不知道这是 PDF 生成器的问题,还是 chrome 插件的问题.根据 PDF 规范,PDF 文档的第一行必须包含 PDF 版本,但我并不完全清楚 ^M 是否是有效的行分隔符.

I don't know if this is a problem with the PDF generator, or with the chrome plugin. According to the PDF specification the first line of a PDF document has to contain the PDF version, but it's not completely clear to me if the ^M is a valid line separator.

更多推荐

无法在 Chrome 中加载 PDF 文档

本文发布于:2023-11-27 22:54:53,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1639947.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:加载   文档   Chrome   PDF

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!