javascript 如何禁用 iframe 中的 pdf 工具栏下载按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20328820/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to disable pdf toolbar download button in iframe
提问by abhi
I have a web service which will return pdf stream for a given document id and I will set the content type to application/pdf and write the out put to IFRAME upto this point I am done and OK! My problem is : My requirement is to disable the pdf download toolbar button in IFRAME, is there any way using JavaScript or j query to disable the PDF toolbar buttons, i tried some thing like this:
我有一个 Web 服务,它将返回给定文档 ID 的 pdf 流,我将内容类型设置为 application/pdf 并将输出写入 IFRAME 到此为止我完成了,OK!我的问题是:我的要求是禁用 IFRAME 中的 pdf 下载工具栏按钮,有没有办法使用 JavaScript 或 j 查询来禁用 PDF 工具栏按钮,我尝试了这样的事情:
<iframe src="view/1.pdf?page=hsn#toolbar=0" width="875" height="95%" id="iframe11">
<p>Your browser does not support iframes.</p>
</iframe>
I tried setting toolbar=0 for iframe tag but it dint work. an anyone please tell me how to achieve this ?
我尝试为 iframe 标记设置工具栏 = 0,但它不起作用。任何人请告诉我如何实现这一目标?
回答by Jiteen
I hope I am not very late to reply. But here's is something you can do to prevent the users. Use iFrame to display your PDF and make sure that you are displaying using Google. I used the following code :
我希望我不是很晚才回复。但是您可以采取以下措施来阻止用户。使用 iFrame 显示您的 PDF,并确保您使用 Google 进行显示。我使用了以下代码:
<iframe src="http://docs.google.com/gview?url=http://www.tutorialspoint.com/php/php_tutorial.pdf&embedded=true" style="width:600px; height:500px;" frameborder="0">
</iframe>
Here you can simply change the url=http://www.tutorialspoint.com/php/php_tutorial.pdf
and replace it by your own URL where you kept your PDF.
在这里,您可以简单地更改url=http://www.tutorialspoint.com/php/php_tutorial.pdf
并将其替换为您保存 PDF 的自己的 URL。
回答by user8565193
Use embed tag instead iframe tag:
使用 embed 标签代替 iframe 标签:
<embed src="http://localhost/yourpdf.pdf#toolbar=0" style="width:600px; height:500px;">