0

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?

Ameer Elsherif
  • 71
  • 2
  • 10
  • 2
    can they be read online? – samezedi May 27 '18 at 23:47
  • Yes, they can be read online if the user has subscribed and paid for it. – Ameer Elsherif May 27 '18 at 23:49
  • 3
    Possible duplicate of [Prevent PDF file from downloading and printing](https://stackoverflow.com/questions/4930914/prevent-pdf-file-from-downloading-and-printing) – hassan May 27 '18 at 23:50
  • Also , https://stackoverflow.com/questions/10441937/php-to-view-pdf-on-web-page-and-disable-user-to-download – hassan May 27 '18 at 23:51
  • in order for you to achieve what you've asked it's better they don't see the pdf file at all, if they are not subscribed users – samezedi May 27 '18 at 23:51
  • When user pays for a PDF then enter a record in the database indicating they've paid. User never sees the real location of the PDF. When they are logged in, they have a download button, and that button gets the contents of the PDF and outputs it to the browser. For a great example, see CodeIgniter's download helper, and the force_download function. – Brian Gottier May 27 '18 at 23:58
  • 4
    If the information is visible on the users screen, its already on their machine. – castis May 28 '18 at 01:10

3 Answers3

0

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

0

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/

Mike Aron
  • 550
  • 5
  • 13
0

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

Lex
  • 4,749
  • 3
  • 45
  • 66