How to protect PDF files from being downloaded or copied

三世轮回 提交于 2020-01-21 19:30:39

问题


I'm developing a new website with PHP & MySQL.

The website is for an online eBook library that grant access to its books based on paid subscription plans.

So, I need to make sure the PDF files of these books are well protected and can't be saved, downloaded, or in anyway copied.

How can I do that?


回答1:


I suggest you to convert the PDF into an image , and display the first page or as you like, check this library it can be useful Imagemagick




回答2:


I think this is not a PHP or MYSQL solution. PDF's have a "protected mode". There you can disable printing the pdf. You should look for a server side pdf recreation tool that can recreate the pdf in protected mode and serve the user this file. Take a deeper look into PDF functions. I think i can remember that there should also a trial mode also and the ability to view only on 1 device. Here a link for more info: http://www.dummies.com/software/adobe/acrobat/restrict-who-can-edit-or-print-pdf-documents/




回答3:


You'll be able lock down the files from unwanted downloads. But redistribution or sharing login details will be a battle.

Some options I can think of

Option 1: You can handle this yourself on the server. Housing the PDFs outside of the public Apache directory (so there is no way a URL can reach it). Then with a PHP function read the contents of the file and stream it to the browser. Streaming a large file using PHP

Option 2: Use something like AWS S3. You can lock down the bucket so there is no public access. And generate signed URLs as needed. They'll be unique urls which you can specify a time limit of availablity. AWS S3 The security of a signed URL as a hyperlink



来源:https://stackoverflow.com/questions/50557492/how-to-protect-pdf-files-from-being-downloaded-or-copied

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