How to restrict user from downloading or saving pdf file? [duplicate]

风格不统一 提交于 2019-12-25 08:16:44

问题


Possible Duplicate:
Prevent PDF file from downloading and printing

In my current symfony project (in admin section) I uploaded pdf file and open it by using JavaScript, but I want to restrict user to download or save for that pdf?

So is it possible to me to restrict user to download or save pdf?

I means user can only view content of that pdf, i want to disable download or save options of all browsers for that pdf.

pdf file is open from server only.

Action File Code:

echo "<span onclick=\"clickme('$pdf_name')\";>view</span>";

Success File Code:

<script type="text/javascript">
   function clickme(file_name){
     window.open(file_name); 
   }   
</script>

Thank you in advanced.


回答1:


It's practically impossible to prevent people from downloading anything, much less PDF's. I'm afraid you're gonna have to go with alternatives, such as only showing a preview of the document or using watermarks.




回答2:


The simple fact is that if the user is viewing the PDF file, they have already downloaded it to a temporary directory on the computer.

I see questions like this all the time (mostly for GIF/JPEG), but you have to understand that a solution to prevent this is completely impossible because you have already lost the game when you sent the PDF down to the user's machine.

The best you can hope for is to make it difficult on the user to do this, but with enough effort there is no way to stop them. For example, how would you prevent them from taking screenshots of the image, or just grabbing it from the browser cache directly?

You might have luck thwarting non-savvy users by setting the security flags in the PDF file itself.




回答3:


yes It Can be by Force browser in file Header

it force browser To download Instead view it is down By Htaccess and You Can Do By PHP Too

<FilesMatch "\.(?i:pdf)$">
   ForceType application/octet-stream
   Header set Content-Disposition attachment
</FilesMatch>

see below link I hope Help You

link1

link2

link3



来源:https://stackoverflow.com/questions/14664923/how-to-restrict-user-from-downloading-or-saving-pdf-file

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!