Html 在网页上嵌入 PDF 并防止下载
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10129733/
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
Embed PDF on a webpage and prevent download
提问by 71GA
Is there a way to embed a PDF document on a webpage and at the same time disabling download? If possible I would prefer an html5/css3 solution. If no other way is possible I'd go with something else.
有没有办法在网页上嵌入 PDF 文档并同时禁用下载?如果可能,我更喜欢 html5/css3 解决方案。如果没有其他方式可能,我会选择其他方式。
采纳答案by Morcer
回答by mirecsvk
Actually, it is possible, you can adjust in your Google Drive option "Prevent viewers from downloading" Then set PDF file public, so everyone can view PDF in Viewer, but none can download it. I hope, that this will help for some.
其实是可以的,你可以在你的Google Drive选项中调整“阻止查看者下载”然后将PDF文件设置为公开,这样每个人都可以在查看器中查看PDF,但没有人可以下载它。我希望,这会对某些人有所帮助。
回答by Michael Slade
Short answer is, it can't be done. The only way to view a PDF document without any kind of conversion is via the adobe PDF plugin, and that invariably allows the document to be saved. On top of that, it's trivial to use various tools to get the url of the PDF and download it from there.
简短的回答是,这是不可能的。无需任何类型转换即可查看 PDF 文档的唯一方法是通过 adobe PDF 插件,并且始终允许保存文档。最重要的是,使用各种工具获取 PDF 的 url 并从那里下载它是微不足道的。
If you want to avoid sending the actual PDF document, you could create a server-side script that converts the PDF document to a series of PNG or JPG images behind the scenes. You can do this with ghostscriptfor example.
如果您想避免发送实际的 PDF 文档,您可以创建一个服务器端脚本,在幕后将 PDF 文档转换为一系列 PNG 或 JPG 图像。例如,您可以使用ghostscript执行此操作。
But then, the actual content of the document still reaches the user, only in a different format. If this is not satisfactory for you, there are varioustechniquesyou can use to prevent mostusers from saving the images, but these are easily circumvented by a sufficiently technically savvy user.
但是,文档的实际内容仍然会到达用户,只是格式不同。如果这对您不满意,您可以使用多种技术来防止大多数用户保存图像,但技术娴熟的用户很容易绕过这些技术。
回答by FiringBlanks
Yes. Yes there is:
是的。就在这里:
<div id="pdf">
<object width="100%" height="650" type="application/pdf" data="[ImageURLHere]#zoom=85&scrollbar=0&toolbar=0&navpanes=0" id="pdf_content" style="pointer-events: none;">
<p>Insert your error message here, if the PDF cannot be displayed.</p>
</object>
</div>
The pointer-events: none
styling will also prevent users from right-clicking the PDF and downloading.
该pointer-events: none
造型也将阻止用户右键点击PDF和下载。
回答by Dario Rusignuolo
just add #toolbar=0
to the url of the pdf
只需添加#toolbar=0
到pdf的网址
回答by user9138873
You can download the PDF.js and modify these 2 files: viewer.html and viewer.js, remove/modify the corresponding buttons/actions in order to disable downloading/printing, and you can furtherly disable right click menu items.
您可以下载 PDF.js 并修改以下 2 个文件:viewer.html 和 viewer.js,删除/修改相应的按钮/操作以禁用下载/打印,您还可以进一步禁用右键菜单项。
回答by Puce
You can use SlideShare, you can set a read password, prevent users from downloading in the settings, and even create a secret link so only users with it can open it. I am sure there are ways to circumvent this, but at least it's not immediate.
您可以使用SlideShare,您可以设置读取密码,在设置中阻止用户下载,甚至创建一个秘密链接,以便只有拥有它的用户才能打开它。我相信有办法规避这一点,但至少不是立竿见影的。