'How to protect PDF files from being downloaded or copied
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?
Solution 1:[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
Solution 2:[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/
Solution 3:[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
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Mostafa Aguerram |
Solution 2 | Mike Aron |
Solution 3 | Lex |