gpt4 book ai didi

javascript - 如何在所有浏览器中使用 PDFObject.js

转载 作者:行者123 更新时间:2023-12-03 04:57:36 24 4
gpt4 key购买 nike

我想在我的 Web 应用程序中插入 ViewerPDF。为此我下载了 PDFObject。现在我的页面中有这段代码:

<script src="Scripts/PDF/pdfobject.js" type="text/javascript"></script>
<script>
var url ="urlPDF";
var container = document.getElementById("divID");
var options = {
fallbackLink: "<p>This is a <a href='[url]'>fallback link</a></p>",
height: "500px",
width: "500px",
pdfOpenParams: {
view: 'FitV',
pagemode: 'thumbs',
search: 'lorem ipsum'
}
};
PDFObject.embed(url, container, options);
</script>

使用此代码,如果我尝试使用 Internet Explorer 打开我的samplePage.html,我可以看到 PDF。如果我尝试使用 Mozilla Firefox 打开samplePage.html,我可以看到以下内容: enter image description here

如果我尝试使用 Google Chrome 打开samplePage.html,我永远看不到。

最佳答案

如果 Mozilla 显示 PDF 的源代码(如屏幕截图所示),并且 Chrome 无法识别该文件(不会打开它),则您可能没有在服务器上设置正确的 MIME 类型。确保文件作为应用程序/PDF 提供。

(请注意,由于 Mozilla 删除了导航器 MIME 类型数组,PDFObject 2.0 无法在最新版本的 Firefox 中运行。)

关于javascript - 如何在所有浏览器中使用 PDFObject.js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42369685/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com