我想在通过 iframe
呈现时删除 PDF 附带的工具栏。当我将 #toolbar=0
与 URL(或文件路径)一起使用时,它在 Chrome、IE 等浏览器中运行良好。但它在 Firefox 中不起作用。
谁能告诉我哪里做错了?
这是我的代码。
<html>
<body>
<iframe src="Reports/reports.pdf#toolbar=0" width="100%;" height="80%">
</iframe>
</html>
最佳答案
我认为它还取决于浏览器打开 PDF 的应用程序/插件,它的工作方式不同并且它可能会忽略那里的指令(取决于浏览器、插件、平台、PDF 查看器)。
这里的一般建议是在 URL 末尾使用这些“指令”:
#toolbar=0&navpanes=0
您也可以尝试来自 http://blogs.adobe.com/pdfdevjunkie/web_designers_guide 的建议:
使用 PDFObject 嵌入
You could use basic HTML markup to embed PDF files in your page but there is a more elegant solution out there. Take a look at PDFObject by Philip Hutchison. PDFObject is a pretty easy scripting tool for dynamically embedding PDF files into web pages. It uses JavaScript to inject an element into the DOM tree of your HTML file. There’s even a handy code generator to help you out with all of the extra parameters you may need.
<script type="text/javascript" src="scripts/pdfobject.js"></script>
<div id="pdf1" style="width:500px; height:375px;"></div>
<script type='text/javascript'>
var myPDF = new PDFObject({
url: 'ConferenceGuide.pdf',
pdfOpenParams: {
view: 'Fit',
scrollbars: '0',
toolbar: '0',
statusbar: '0',
navpanes: '0' }
}).embed('pdf1');
</script>
PDFObject
的链接在这里:http://www.pdfobject.com/ (取自他们的网站)
小更新
免责声明:为避免对该主题的进一步猜测,您需要考虑到您的客户/顾客可能在他们的机器上安装了不同的插件和 PDF 查看器,以及不同版本的应用程序和插件,因此以上解决方案均不是将在 100% 的情况下工作。例如,Adobe 为 Firefox 安装了单独的插件,它们有不同的版本和不同的内置行为。
这里是关于 FF and Reader X 的棘手案例的引用资料,正如上面所说的好例子。
关于javascript - 尝试在 Firefox 中使用 iframe 进行渲染时,如何隐藏 pdf 文件附带的工具栏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36714203/